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 stores the current user name, and then queries the users whose logon time (Last activity time) is later than the previous two minutes in the database. if the user with the same session is found, the user is regarded as the current user, displays the user name. Otherwise, a link is displayed about the session in the php chat room.
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.