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
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.
Cookies are browser-specific. If you use more than one browser in your system, then each browser will have their own set of cookies.
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.
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.
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.