Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI know that we can use some snippets or plugins to save the client history but this work for the login clients as I know.
My question is how to do the same thing but for unlogin users. Let's say I am a user without an account and I have viewed some posts in the website. So the next time I want to visit this site I want to see my latest posts that I have seen from the last visit in a page called history.
It's like YouTube history page but without login so that everything is saved in the user's browser like a cookie file or something else.
To use cookies is easy if I followed the php documentation but I want to use it in wordpress so that why I am asking my question here.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI know that we can use some snippets or plugins to save the client history but this work for the login clients as I know.
My question is how to do the same thing but for unlogin users. Let's say I am a user without an account and I have viewed some posts in the website. So the next time I want to visit this site I want to see my latest posts that I have seen from the last visit in a page called history.
It's like YouTube history page but without login so that everything is saved in the user's browser like a cookie file or something else.
To use cookies is easy if I followed the php documentation but I want to use it in wordpress so that why I am asking my question here.
Share Improve this question edited Aug 16, 2019 at 17:36 Maher Aldous asked Aug 16, 2019 at 9:39 Maher AldousMaher Aldous 1194 bronze badges1 Answer
Reset to default 0You can use cookie to store information in the visitor's browser.
In your single post template, you can set the cookie by using
setcookie( 'last_post_id', get_the_ID() );
And on your other page, you can manage the last post that the user has visited.
$last_post_id = ! empty( $_COOKIE['last_post_id'] ) ? $_COOKIE['last_post_id'] : false;
if( $last_post_id ) {
// do something with the cookie.
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745236577a4617929.html
评论列表(0条)