A variety of websites often have similar "keep 30 days automatic login" option, how do they do the time to save the login status?
Why my website, in the local time, as long as the browser opens, the account will remain logged in, but after uploading to the server, as long as there is no operation or refresh the page, the login status will be invalid (I use the TP framework, session (' Admin_uid ') record login status)?
This is my login verification code,
validateLogin();//代表登录验证操作if($result){//代表验证成功 括号内进行的是存session以及页面跳转操作}//要保存指定时间的登录状态,这里应该怎么写?
Reply content:
A variety of websites often have similar "keep 30 days automatic login" option, how do they do the time to save the login status?
Why my website, in the local time, as long as the browser opens, the account will remain logged in, but after uploading to the server, as long as there is no operation or refresh the page, the login status will be invalid (I use the TP framework, session (' Admin_uid ') record login status)?
This is my login verification code,
validateLogin();//代表登录验证操作if($result){//代表验证成功 括号内进行的是存session以及页面跳转操作}//要保存指定时间的登录状态,这里应该怎么写?
You set up session
in fact will automatically expire after a certain period of time, but the automatic landing (keep logged on) the implementation of this function is cookie
to achieve, you need to put your account password through encryption means to enter cookie
, and if the site session
does not exist, and then take out cookie
Information decryption, in-house do a landing on the good, so that the realization of automatic landing, you can also cookie
set the validity period, the final effect can be achieved ~
The browser settings cookie expiration time is set to 30 days so that you can stay logged in.
Http://www.thinkphp.cn/topic/4484.html
Originally wanted to write about. Find out on the internet there are ready-made ... Let me give you a reference.
Typically, login expiration is cookie,session these two expire and can be set to a valid time by a cookie to achieve
First, when the user first logs on, the user information is encrypted, and then the cookie is stored on the client, valid for 30 days,
Then, when the user nth access, if the status is not logged in, then read the user information from the cookie, decrypt, verify the user information, if passed, it automatically log in
session_id with Data inventory