Questions about cookies and session logins

Source: Internet
Author: User
Cookies and Session login issues
There are a few questions to help you answer

1. How to determine if the user is logged in after successful login
I wrote the session username and password to the database in the correct comparison to count the login
Some say it's just a matter of determining if a session exists, even if login does not exist jump to login page
is the second method safe? Can the session and the cookie be forged directly on the login?

2. I only used the session login, now want to increase the automatic storage of cookies login function, the session still need to use it?
What's the whole idea?

------Solution--------------------
To determine if you are logged in, just determine if there is a record in the session.
If you are worried about a fake session, then you have the user name and password in the session will not worry about forgery and leaks?

Need or need, after all, cookies are stored in the client, but also in the network transmission, the probability of being stolen is very large

------Solution--------------------
Explore

A friend gave me a way
Just add the following sentence after the set session.
Setcookie (Session_name (), session_id (), time () + 2592000, "/");

But I don't quite understand the meaning of this remark.

------Solution--------------------
Automatic login requires the use of cookies, or how the server knows who is who?
The cookie requires a user name with an expiration period, and an identity string that can be processed by the user's information.
When PHP receives a cookie, it thinks that the user is logged in
If verification is required, the user's identity string is computed and the incoming identity string is compared
  • 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.