PHP: operate sessions of multiple users and threads to automatically update session values in user login status-PHP source code

Source: Internet
Author: User
Ec (2); Code: & nbsp; $ my_session_id $ _ COOKIE [session_name ()]; Save the sessionid of the current employee; session_start ();....... some operations, such as verifying whether the current user has the permission to operate on session updates {here we can cyclically operate on the sessionsession_write_close (); & nbsp; se script ec (2 ); script

Code:

$ My_session_id = $ _ COOKIE [session_name ()]; // Save the session id of the current employee;

Session_start ();

Some operations, such as verifying whether the current user has the permission to perform session update

{// Here you can cyclically operate sessions of multiple other users

Session_write_close ();
Session_id ($ _ refresh_user_sessoin_id); // $ _ refresh_user_sessoin_id is the id of the session of another user to be updated; The session_id () function can be used without parameters to obtain the sessionid of the current user, however, after session-start (), use $ _ COOKIE [session_name ()];
Session_start ();

... // Operate on the session to be operated.

} // The end of loop Processing

Session_write_close ();
Session_id ($ my_session_id); // restores the session of the 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.