Access to non-current-user sessions data in PHP

156 Views Asked by At

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?

3

There are 3 best solutions below

1
gahooa On

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

0
user292021 On

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

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

where 1234 is the session id

0
pestilence669 On

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.