按值取消会话?

is it possible to unset session by it's value ?

i have a chat application and it identifies user/pears using session called username , i want to be able to unset each session from admin panel .

i have user session value in admin and i can send it to the chat app to unset that specific user by ajax .

$kick_out = $_post['username'];
if($_session['username'] == $kick_out )
unset( $_session['username']  );

but the thing is i don't want to unset all the $_session['username'] , just the one that has $kick_out value

Then make the condition:

if{$_session['username'] == $kick_out} unset( $_session['username']);

in your code you are assigning the kickout value , you are not making a comparison against it. if you have a $_SESSIONS["username"] can you var dump it so we get a glue what is it? object?array?multidimensional array?string?

You cannot modify other users' sessions. If you want to forcefully logout someone you need to store a flag in your database which is checked on every request from a logged-in user.

If you want to unset someones session, it's impossible.You can store session id to database and when you want to kick someone, set session id empty and every time check if $_SESSION at user is same as from database where username equal to logged in username..