PHP session_id usage, please advise. ~
This post was last edited by Eiysxd on 2014-08-10 17:23:40
See a problem on the OSC.
The problem is as follows:
Ask a question, the cookie can record the user name and password to realize the automatic login website. The idea is that users log in to use JS to obtain data, the creation of cookies stored in the user's computer, the next time the login automatically read whether there is a cookie file, there is loading login it.
How can this username and password be encrypted and saved? Is it just an ordinary user name and an encrypted password?
One user replied:
Don't tease, how can you save the password in the client's cookie, automatic login is to save the session ID to the cookie implementation
how can I use PHP's session_id to generate unique values? , the principle should be that the user login to the site, the user's session_id write to a column of the database, and then also write to the cookie, when the user opens the site again there will be a function is to retrieve the user whether there is the site's cookies, and then read, and database verification To return the user's logon status.
But how is session_id going to use it? How do you implement a unique value? Please advise.
------Solution--------------------
The unique value generated by the server, as long as it is the same conversation and does not have a period, the access to the session_id () is the same.
Session_Start ();
Echo session_id ();
?>
Every time, unless the browser is closed, it will regenerate again.