PHP, the operation of multiple users, multiple threads of the session, implementation of user login status session value of the automatic update

Source: Internet
Author: User
Tags session id

Code:

$my _session_id=$_cookie[session_name ()];//saves the session ID of the current person;

Session_Start ();

...//Some operations, such as verifying that the current user has permission to operate session updates

{//here can loop to manipulate multiple other users ' sessions

Session_write_close ();
session_id ($_refresh_user_sessoin_id);//$_refresh_user_sessoin_id is the ID of the session of the other user who wants to update; SESSION_ID () function without parameters can obtain the current user's SessionID, but need to session-start (), otherwise use $_cookie[session_name ()];
Session_Start ();

..//To operate the session to be manipulated.

End of}//loop processing

Session_write_close ();
session_id ($my _session_id);//restore session of current user
Session_Start ();



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.