简体   繁体   中英

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 ?

不, $_SESSION是浏览器所独有的

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. Ie, 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM