Some questions about logging in with the session

Source: Internet
Author: User
Some questions about login with session
So, I wrote a login, using the session. When you log in, store the SessionID with Redis.

Now I want to implement a function, that is, two users login to the same account, after the login to the front of the login to squeeze out.

One of my ideas is that when you log in, update the SessionID in Redis, log users every time you do the operation, go to Redis to query the SessionID he logged in and the current consistency, inconsistent is not logged in. But will it be too frequent to read Redis? Will there be pressure?

There is another idea, is to log in, it is sure to get from Redis to the last saved SessionID, can pass this sessionid to the session file to destroy, so that the user before the login to get the session file, even if it is not logged in. This method only reads the database at the time of log-in, and reads the database less frequently. But, one thing, I don't know how to destroy files by SessionID.

Daniel, which of these two methods is better? In the second method, how do I destroy a file by SessionID? Or is there a better way? Thank you for your advice

------Solution--------------------
The second method is not clear. Is it said that when B logs in, it gets session_id and then destroys a session file? How can this be done?
------Solution--------------------
when you log in, store the SessionID with Redis .
Do you use the user name to do the key, or use SessionID to do the key?

If you do a key with a user name, then only one username exists in Redis, and his value (SessionID) is not yours, even if you don't log in
If you use SessionID to do the key, then you need to query the corresponding key according to the user name (get multiple SessionID)
Traversing these sessionid is not your sessionid to do
session_id ($sessionid);
Session_Start ();
Unset_session ();
Last do
SESSION_ID ($ your sessionid);
Session_Start ();

------Solution--------------------
Redis is memory-based and the session is file-based
Are you afraid of hard disk damage?
------Solution--------------------
Is there anything that you don't know?
No worries, you know?
  • 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.