PHP session_id usage, please guide.

Source: Internet
Author: User
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.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.