note 14194 deleted from ref.session by sniper
| From: | sniper@php.net | Date: | Tue, 21 Jan 2003 03:24:08 +0000 |
| Subject: | note 14194 deleted from ref.session by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42492@lists.php.net to get a copy of this message | ||
Simple/Effective Session Handling lib for your (part of) website.
Use near top of pages with e.g.
include_once("session.php"); loadMySession();
<?php
$SID = ""; // declare global
function constructSession() {
session_start();
$GLOBALS["SID"] = "PHPSESSID=".session_id();
session_register("var1"); $GLOBALS["var1"] = "var1_Default";
...
}
// not session_destroy() if independent sections on website
function destroyMySession() {
session_start();
session_unregister("var1");
...
}
function loadMySession() {
session_start();
$GLOBALS["SID"] = "PHPSESSID=".session_id();
$GLOBALS["var1"] = $HTTP_SESSION_VARS["var1"]; // overwrites params from
POST
...
}
// I couldn't write to $HTTP_SESSION_VARS[], so using $GLOBALS
function setSessionVar ($var, $val) { $GLOBALS[$var] = $val; }
function sessionVar ($var) { return $GLOBALS[$var]; }
?>