1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

session alive across browsers?

Discussion in 'PHP' started by rekha, Nov 30, 2009.

  1. rekha

    rekha New Member

    Joined:
    Jan 17, 2008
    Messages:
    83
    Likes Received:
    0
    Trophy Points:
    0
    Hi,


    How to keep the session alive across browsers?Suppose I have logged in my site using firefox.If I open IE and give my site,it will be automatically logged in.How to do this?



    Regards
    Rekha
     
  2. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    I have not heard of such a scenario before. According to my understanding, the session variables are stored in the storage space specific to a particular browser. So I think this is not possible.

    Anyways, will let you know if there is a way.
     
  3. technica

    technica New Member

    Joined:
    Dec 15, 2007
    Messages:
    107
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    No i too agree that this is not possible.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Impossible.
     
  5. sameer_havakajoka

    sameer_havakajoka New Member

    Joined:
    Sep 14, 2009
    Messages:
    271
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Sleeping
    Location:
    Hava Ke Paro Me
  6. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    Cookies are browser-specific. If you use more than one browser in your system, then each browser will have their own set of cookies.
     
  7. pete_bisby

    pete_bisby New Member

    Joined:
    Nov 11, 2007
    Messages:
    48
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Software Developer/Analyst, PB
    Location:
    Manchester, England
    Home Page:
    It can be done, but you need to know the session key/ID - easiest way is to put the session key/ID as part of the URL (e.g. http://www.a-website.com?id=1a2b3c1a2b3c1a2b3c1a2b3c1a2b3c4d).

    You can then use this key in another browser to re-register the session using the existing session key/ID, using session_id() passing the session key/ID as the parameter.

    However, revealing session keys/IDs as part of the URL isn't a good idea - goes against all security principles.
     
  8. rekha

    rekha New Member

    Joined:
    Jan 17, 2008
    Messages:
    83
    Likes Received:
    0
    Trophy Points:
    0
    Can you give me a simple example.I can't figure it out what you are exactly telling?Pls...
     
  9. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    I think this is what pete_bisby tries to say:

    When you had registered in a web browser, you can get the session ID details from that browser and then use the same session ID to re-register when the user loads the same page in another web browser.

    But, my doubt is whether the session is used or another session created with the same session ID? I hope the latter only will happen... Correct me if I am wrong.
     
  10. pete_bisby

    pete_bisby New Member

    Joined:
    Nov 11, 2007
    Messages:
    48
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Software Developer/Analyst, PB
    Location:
    Manchester, England
    Home Page:
    It actually uses the same session file that is created on the server, effectively sharing the same session variables between two web browsers.

    Session variables are not stored on the individual user's computer or the web browser - they are stored on the web server, defined in the PHP.INI file. The file that is created is a simple text file with serialised information, relating to the session variables you define when creating the $_SESSION array. The session key/ID is part of the filename of this text file.

    To be honest, I cannot think of any good reason why you want to do this, only that it is possible. It certainly isn't "best practice" to share session keys/IDs, simply because the information stored is supposed to be secure.
     

Share This Page