[ create a new paste ] login | about

Link: http://codepad.org/eQ3oZY1Z    [ raw code | output | fork ]

zuul - PHP, pasted on Jun 14:
<?php
function killsession()
{
  // start the session, if started before, comment
  session_start();

  // Unset all of the session variables. 
  $_SESSION = array();

  // destroy the session, and not just the session data!
  if (ini_get("session.use_cookies")) {
    $params = session_get_cookie_params();
    setcookie(session_name(), '', time() - 42000,
        $params["path"], $params["domain"],
        $params["secure"], $params["httponly"]
    );
  }

  // get a new ID for the session
  session_regenerate_id();

  // destroy the session.
  session_destroy();

  // direct user
  header("Location: index.php");
}

session_start();

$_SESSION['userid']=25;
$_SESSION['userName']='Super BuBu';

print_r($_SESSION);

killsession();

print_r($_SESSION);
?>


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Warning: session_start(): open(/tmp/sess_ef1d451c39234d2958aad97bac41dc67, O_RDWR) failed: No such file or directory (2) on line 29

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /t.php:29) on line 29

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /t.php:29) on line 29
Array
(
    [userid] => 25
    [userName] => Super BuBu
)

Warning: Cannot modify header information - headers already sent by (output started at /t.php:29) on line 16

Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent on line 20

Warning: Cannot modify header information - headers already sent by (output started at /t.php:29) on line 26
Array
(
)


Create a new paste based on this one


Comments: