Questions about session in php chat rooms

Source: Internet
Author: User
Tags php session
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.

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.