How to use session when disabling cookies on the PHP client

Source: Internet
Author: User
Method 1: Add a PHPSESSID $ sid on each hyperlink // prevent the returned initial page from generating a new sessionif (isset ($ _ GET [& quot; PHPSESSID & quot;]) {session_id ($ _ GET [& quot; PHPSESSID & quot;]) ;}// start a sessionsession_start (

Method 1: Add a PHPSESSID = $ sid on each hyperlink

// Prevent new sessions from being generated when the initial page is returned
If (isset ($ _ GET ["PHPSESSID"]) {
Session_id ($ _ GET ["PHPSESSID"]);
}
// Start a session
Session_start ();
// Obtain the session_id () of the current session ()
$ Sid = session_id ();
// Add the PHPSESSID = $ sid parameter to each link

Other pages can be obtained as follows:
If (isset ($ _ GET ["PHPSESSID"]) {
// Set the current session to the initial session, and the session_id () is consistent.
Session_id ($ _ GET ["PHPSESSID"])
}
Session_start ();

Method 2: Use the SID constant to replace PHPSESSID = $ sid on the link (the SID value is similar to PHPSESSID = sddg34r593dfdlksrewr)
If (isset ($ _ GET ["PHPSESSID"]) {
Session_id ($ _ GET ["PHPSESSID"]);
}
// Start a session
Session_start ();


Other pages can be obtained as follows:
If (isset ($ _ GET ["PHPSESSID"]) {
// Set the current session to the initial session, and the session_id () is consistent.
Session_id ($ _ GET ["PHPSESSID"])
}
Session_start ();

Method 3: Use session. use_trans_sid = 1, which is configured in php. ini.
In this way, the SID (href, location, action) is automatically added to the url. note: SID is not added to js redirection)

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.