top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

How do I unset or destroy sessions in PHP?

0 votes
50 views
posted Aug 15, 2013 by Meenal Mishra

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote
 
Best answer

Unset will destroy a particular session variable whereas session_destroy() will destroy all the session data for that user. Now use them accordingly.

unset($_SESSION['name']); // will delete just the name data
session_destroy(); // will delete ALL data associated with that user.

Source: http://stackoverflow.com/questions/5697822/session-unset-or-session-destroy

answer Aug 15, 2013 by anonymous
Similar Questions
0 votes

I want to write online user module for my site and I want to check $_SESSION['userID'] to find all users id who loged in but when I echo this code its return only current user detail how I can see all sessions?

foreach($_SESSION as $k => $v)
{
echo $k."----------".$v;
}

or how I handle online users?

0 votes

I have the following (below) session code at the top of each page.. The 'print_r' (development feature only) confirms that on one particular page I do log out as the session var = (). but, on testing that page via the URL I still get to see the page and all its contents - session var() -.. the page has the following session_start, DOCTYPE Info then containing meta info

error_reporting (E_ALL ^ E_NOTICE);
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
print_r($_SESSION);
+2 votes

I'm having a problem getting my objects out of the $SESSION variable. I am storing an ordinal array of associate arrays where one of the associate array elements is an object. Unfortunately, when I pull it back out, the object is "broken" with "__PHP_Incomplete_Class" errors.

From what I can read this has something to do with 'serialization' - i.e., the emerging object must be unserialized (http://php.net/manual/en/function.unserialize.php ). However, I can't get it to work.

Any tips on how that is done, or what I should do instead?

This program is being developed on a testing server that can then be put on a production server.

Here are my server specs:
Apache Version : 2.2.17
PHP Version : 5.3.3
MySQL Version : 5.5.8


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...