Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1415420
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.
}
本文标签: cookiesHow to save history in the client39s browser without login
版权声明:本文标题:cookies - How to save history in the client's browser without login? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745236577a2649075.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论