Oto Shavadze
Oto Shavadze

Reputation: 42773

Deleting session from one browser in second browser

For example In one browser (say in chrome) we run this code

session_start();
$_SESSION['login'] = "Jon";

Its possible to delete this session using other browser (say firefox)? that is, what code may run in firefox, for deleting $_SESSION['login'], which value is Jon and which is started in chrome ?

Upvotes: 1

Views: 121

Answers (3)

Alex Howansky
Alex Howansky

Reputation: 53573

See Passing the Session ID page. As long as the second browser passes the same ID as the first, you're effectively using the same session. I.e., yes you can do this, but you need to come up with some way for the second browser to get a hold of the session id that was created by the first.

Edit: To answer the second question asked in your follow-up comment, it depends on the session storage mechanism you use. If you're using a database table, then you'll probably have the userid as a field on that table, enabling you to also DELETE FROM session WHERE userid = 'Jon' when the userid is disabled.

Upvotes: 1

Benny Hill
Benny Hill

Reputation: 6240

The only way would be on the server side. You would have to figure out which sess_* file (on Ubuntu 12.04 these are found in /var/lib/php5) is associated with the Chrome browser and delete it.

Upvotes: 0

Paul Dessert
Paul Dessert

Reputation: 6389

No, the $_SESSION is unique to the browser

Upvotes: 2

Related Questions