How to separate data in Session variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Beginner1
    New Member
    • Feb 2007
    • 16

    How to separate data in Session variable

    Hi All,

    If someone logs in my system I set up a few Session variables such as user type (admin, user, etc.) and a few other privileges and settings.
    Code:
    session_start ();
    
    $_SESSION['id'] = $row['user_id'];  
    ...
    ...
    On one server I keep the production version and the test one.

    My problem is if I open both versions in different tabs of the same browser both systems read/writhe data form the same $_SESSION variable. I don't want the real(production ) settings to be destroyed while testing.

    My feeling is that I should use session_name() function, but I don't know how???

    I've just put session_name before the session_start it does not help:(

    session_name ('production');
    session_start ();

    Thanks!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    So your have two servers, each of them using the the same session data, and you are worried that one of them might damage the session data of the other. Am I right?

    If so, you shouldn't have to worry. Each server should have it's own session. One server can't mess up a session on another server.

    In any case, the session data is only temporary. It is destroyed when you close the browser (by default). Why are you so worried that it will get damaged?

    Comment

    • Beginner1
      New Member
      • Feb 2007
      • 16

      #3
      Hi,

      Thanks for reply!!

      I have one server on which I keep both versions, so if the same user from the same computer opens the test version all production settings are shown in the test one. That's why I want to separate them somehow.

      My customers want to keep their settings available (kept in $_SESSION) for about a week, so I have the following line in my code.

      ini_set('sessio n.gc_maxlifetim e', 604800) // 1 week

      Thank you!

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Originally posted by Beginner1
        My customers want to keep their settings available (kept in $_SESSION) for about a week, so I have the following line in my code.
        Thank you!
        Then you have to use cookies instead of sessions.

        Comment

        Working...