#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Bay Area California
    Posts
    371
    Rep Power
    18

    How to get multiple sessions for one user working?


    I have two seperate PHP applications running on the same server under different root directories. Each application has its own authentication system for which I set two session variables upon signin. The system checks on every screen that the user has these two session variables set or the user is redirected to the sign-in page. When a user signs-out, I destroy all session variables for that user.

    I noticed while testing both apps today in two browser windows in the same browser, that if I sign-out of one app, it seems to be destroying the session for the other app as well and forcing me out of that application. This does not appear to happen when using two different browsers (e.g. Netscape and Safari together).

    So the questions to you all are...
    (1) Are sessions driven by the browser (this appears to be true)? meaning that any particular user from any particular browser can only have one set of session variables going at a time in that browser?
    (2) if #1 is not true, How can I isolate sessions and the session variables so that they work for the same user running both apps, without destroying or overwriting each other's values?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    63
    Rep Power
    15
    I'm not a session expert, but here's what I know (or think I know. )

    Sessions are browswer specific, so if I have IE open and Netscape, yes it is two entirely different sessions and destroying one will have no effect on the other.

    Also, sessions are application specific. So if I have one website, www.mypage.com that has sessions and another site www.mypage2.com that has sessions, destroying one has no effect on the other.

    However, if I have a site, www.mypage.com that has a session and then www.mypage.com/admin that has another session, if I destory all sessions, it will log me out of both pages.

    You can get around it by unsetting a specific session I beleve, but I have never had to do this, so sure you would have to run tests on this.

    PHP Code:
    session_start();
    unset(
    $_SESSION"usreID" ]);
    // if you're using session_register, the function to call is:
    // session_unregister(firstname); 
    If you had another session, say $_SESSION[ "adminID" ], then that would not be destroyed and you could continue to log into that area.

    That's my breif knowledge of sessions. Maybe someone else can expand on this though.

IMN logo majestic logo threadwatch logo seochat tools logo