Summary of session issues in php chat rooms: using Mysql + Apache + php to write a chat room contains a private chat module. each user saves the logon time of the current user to the database during logon, session to save the current user name, and then query the database login time (Last activity time) more than the current time two minutes before the user traversal if found with the development of php chat room about the session
Summary:
Use Mysql + Apache + php to write chat rooms
There is a private chat module. each user saves the logon time of the current user to the database when logging on, the session saves the current user name, and then queries the logon time (Last activity time) in the database) if a user is located two minutes earlier than the current time and finds the same user as the session, the user is regarded as the current user and the user name is displayed. Otherwise, a link is displayed for private chat.
Sends a message. after each message is sent, the current user logon time (Last activity time) is updated. The entire chat room interface is automatically updated using javascript.
But the problem arises. start two browsers. the test shows that after each message is sent, the sessions of the two browsers become the same: the browser with session [username] being 1; the session [username] is a browser of 2; 2 after a message is sent, the session [username] of 1 and 2 is 1 after the message is sent by, and the session [username] of 1 and 2 is 1
I would like to ask if the php session can only be set to one value at a time. This test is performed on the same machine.
------ Solution --------------------
What browser are you using?
------ Solution --------------------
The session is stored on the server.
Your thinking may be faulty.
We recommend that you use the mysql memory engine for session functions.
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.