Does the cookie have an expiration time and the session has no expiration time?

Source: Internet
Author: User
Does the cookie have an expiration time and the session has no expiration time?
 
 
  
The user name or password is incorrect.
 

'; Include $ _ SERVER [DOCUMENT_ROOT].'/template/footer. php'; exit ();} else {echo" $ Login_email ". '. welcome to'. WEBSITE_NAME .'. '; // Write to the session. $ _ SESSION ["save_username"] = "$ login_email";} // sets setcookie. setcookie ("setcookie", "$ login_email", time () + 60); // Set the expiration time for one hour.?>



 
 
 Welcome
 , You have logged on. Log out
         
 Welcome administrator
 , Log out
 Welcome from
 Please register or log on
 


By the way, it seems awkward for me to exit.
Unset ($ _ SESSION); session_destroy (); if (! $ _ SESSION) {echo "log out successfully.
Return to the home page 2 seconds later. ";// Header (" refrech: 2; URL = http://www.09-29.com/"); header (" refresh: 1; url = /");}


Reply to discussion (solution)

The session is implemented based on cookies and cannot be expired.
No output is available before the header function.

Tested several times,
Comment unset ($ _ SESSION); use session_destroy (); the result shows nothing different?

Session_destroy (); I heard that the whole site session is canceled.

I used browser a and browser B to log on at the same time. I logged out in browser a. didn't my browser exit?

The cookie contains a phpsessid. each ssid corresponds to a session file. Have you synchronized your ssid when logging on to different browsers? Obviously, your ssid must be different. In fact, your two browsers correspond to two sessions. what is the relationship between a and B after you cancel a session?

Tested several times,
Comment unset ($ _ SESSION); use session_destroy (); the result shows nothing different?

Session_destroy (); I heard that the whole site session is canceled.

I used browser a and browser B to log on at the same time. I logged out in browser a. didn't my browser exit?


Cookie is used in combination with session. the cookie of each browser is independent. it does not mean that browser a will exit if browser B exits.

Both cookies and Sessions have an expiration time.
The session depends on the cookie.

Session. auto_start is enabled and session_start () is automatically completed ()

The difference is whether session_start () is required before SESSION is used ();


When
Session. auto_start = on
Run session_start () to generate a new session_id.

Session. auto_start = on has the advantage that it will not cause errors at any time because it forgets to execute session_start () or session_start () in the program.
The disadvantage is that if you are using third-party code, you must delete all session_start (). Otherwise, the correct result cannot be obtained.

Ignore the above reply ......

By default, sessions are stored based on cookies. when you cancel a session, you must also cancel the cookie.

Sessionid passed through cookie
You can use session. cookie_lifetime to set the Expiration Time (0 by default)
However, you must pay attention to the cooperation with session. gc_maxlifetime.

In addition
Setcookie ("setcookie", "$ login_email", time () + 60); // Set the expiration time for one hour
This comment is incorrect! Should be one minute

Both session and cookie expire.

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.