求指教cookie有关问题?

WBOY
Release: 2016-06-13 13:28:08
Original
1205 people have browsed it

求指教cookie问题??
想做自动登录的功能就是有个复选框,后面是自动登录那个样的,我知道要用的上cookie,但应该用什么写呢??或者说用什么写好??php还是javascript???如果用php,还是要经过javascript判断下复选框是否已选吧???具体代码应该怎么写呢???求高人指点。最好给个例子。谢谢了

------解决方案--------------------
表单提交到服务器,php当然可以判断用户是否勾选了复选框。
如果你能把这些个概念和前台后台的职责理解清楚,实现起来也就很轻松。我的想法是生成一个随机的字符串到cookie,将其信息写入数据库,用户初次访问时如果有此cookie,则查询数据库中的登录有效时间
------解决方案--------------------
不是很敏感的东西可以放到cookie.直接判断cookie是否存在某个变量就是了.帐号和密码加密后存储在本地.读取的时候做一个逆向还原进行核对.需要代码?
------解决方案--------------------
关cookie什么事,php端设置cookie生命期两周,设置session服务端生命期2周就可以了。

ini_set:

1509 ; After this number of seconds, stored data will be seen as 'garbage' and
1510 ; cleaned up by the garbage collection process.
1511 ; http://php.net/session.gc-maxlifetime
1512 session.gc_maxlifetime = 1440

session_set_cookie_params

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!