简体   繁体   中英

Access to non-current-user sessions data in PHP

Is it possible to access data in other users sessions than the sessions which is active with the currently connecting client ($_SESSION)?

If so, how?

Yes, but it would be a hack. You would have to look at the session storage mechanism and read it directly. I believe it is files by default, stored in /tmp .

If you need to be more precise about it, consider defining your own session storage mechanism and then providing exta hooks to accomplish what you want.

http://www.php.net/manual/en/function.session-set-save-handler.php

Yes, call session_id () before session_start() and specify the ID you're interested in. The same function also returns the current session ID, which you can log or pass along elsewhere. You can do this multiple times, by closing the session, setting a new ID and restarting. It'll transparently provide access ($_SESSION). Remember to set it back, because it'll update the session ID cookie.

you can retrieve the session data by setting the session id:

http://example.com/index.php?PHPSESSID=1234

where 1234 is the session id

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