If I want to unset one variable in current user session then I can use command unset($_SESSION['something']).
Is this possible to unset only one variable from other session in case when I know PHPSESSID value (can I do it without changing current user session)? I would like check if session of PHPSESSID still exist, if exist then unset($_SESSION['something']) of chosen PHPSESSID.
Yes this is possible and you need to know the session id of that session you would like to unset the variable/value from.
If you want to do it with standard PHP functions, it’s not possible without switching the session. With third-party libraries you can do that w/o switching the session.
This is pretty similar to an answer to php destroy a session which is not the current session, but only deleting a specific member:
If you want to find out if that other session was active or not, this is not possible with this method and from within PHP because PHP will create a new, empty session on
session_start()in case it did not exists.The alternative is to work with the session store directly, e.g. by looking for the session file on disc, loading it’s contents, removing a variable and saving it back. A PHP library that is able to do that is Serialized, it ships with an example of a Session File Viewer which might be a good starting point.
See also: How to tell if a session is active?