3
<?php
include('session_sty_chk.php');
session_start();
if(session_destroy()) // Destroying All Sessions
{

//echo "<script>alert('$login_sessionn log out successfully');</script>";
echo"<script>window.location.href = 'index_sty_chk.php';</script>";
//header("Location: index.php"); // Redirecting To Home Page
}
?>

above code is session destroy code.

In my application i am create two session Session name:- 1:-admin, 2:-society user

when i am click on logout button then destoy the bothe admin and society user session.

So sir i want destoy only society user session in the application so help me to solve it.

  • possible duplicate of [How to remove a variable from a PHP session array](http://stackoverflow.com/questions/2231332/how-to-remove-a-variable-from-a-php-session-array) – Gunaseelan Jun 23 '15 at 11:23

2 Answers2

6
unset($_SESSION['society user']);

use this code

Ramki
  • 519
  • 2
  • 9
0

From the php website:

<?php
$session_id_to_destroy = 'nill2if998vhplq9f3pj08vjb1';
// 1. commit session if it's started.
if (session_id()) {
    session_commit();
}

// 2. store current session id
session_start();
$current_session_id = session_id();
session_commit();

// 3. hijack then destroy session specified.
session_id($session_id_to_destroy);
session_start();
session_destroy();
session_commit();

// 4. restore current session id. If don't restore it, your current session will refer to the session you just destroyed!
session_id($current_session_id);
session_start();
session_commit();

?>

Link: http://php.net/manual/en/function.session-destroy.php#114709

AgeDeO
  • 3,137
  • 2
  • 25
  • 57