Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:50:19+00:00 2026-05-28T17:50:19+00:00

If I want to unset one variable in current user session then I can

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:50:20+00:00Added an answer on May 28, 2026 at 5:50 pm

    Is this possible to unset only one variable from other session in case when I know PHPSESSID value

    Yes this is possible and you need to know the session id of that session you would like to unset the variable/value from.

    can I do it without changing current user session?

    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.

    I would like check if session of PHPSESSID still exist, if exist then unset($_SESSION['something']) of chosen PHPSESSID.

    This is pretty similar to an answer to php destroy a session which is not the current session, but only deleting a specific member:

    $unsetFromSessionID = ... ; # set your session id from where you want to unset from
    $unsetVariableName = 'something'; # set the variable name
    
    $backupSessionID = session_id($unsetFromSessionID);
    session_start(); # load session data
    unset($_SESSION[$unsetVariableName]);
    session_commit(); # save changes to disc
    
    session_id($backupSessionID); # switch to current session
    session_start();
    

    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?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want one session variable to be cleaned every 24 hours .I don't want
I want to unset/delete my existing cookie with this: setcookie (user, , time()-1); unset($user);
want to ask user to input something but not want to wait forever. There
I am the administrator of the site. I want unset a particular session, and
I want to do something like this: foreach ($array as $key=>$value except when $key=id)
Can anyone help me to improve this code? I want to delete array if
want to have a Hyperlink-Button in a gridView in which I can display a
Want the function to sort the table by HP but if duplicate HPs then
want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
Want to send the text from my current vb application to the Active Window

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.