<?php
if(!session_id()){
session_start();
}
if (!isset($_SESSION['stack'])) {
$stack = array();
$_SESSION['stack'] = $stack;
}
function push($src) {
$stack = $_SESSION['stack'];
$stack[] = $src;
$_SESSION['stack'] = $stack;
}
function pop() {
return array_pop($_SESSION['stack']);
}
if (!isset($_SESSION['previous'])) {
echo "no prev<br>";
}
if (!isset($_SESSION['current'])) {
echo "no curr<br>";
}
echo "PREV:" . $_SESSION['previous'] . "<br>";
echo "CURR:" . $_SESSION['current'] . "<br>";
$_SESSION['previous'] = (string) $_SESSION['current'];
$_SESSION['current'] = (string) $_SERVER['PHP_SELF'] . ($_SERVER['QUERY_STRING'] ? "?" . $_SERVER['QUERY_STRING'] : "");
if ($_SESSION['current'] == $_SESSION['previous']) {
echo "POP<br>";
pop();
$_SESSION['previous'] = end($_SESSION['stack']);
} else {
echo "PUSH<br>";
push($_SESSION['previous']);
}
?>
this file shall be inlcuded in every page. but while debugging this, the session variables where gone till the next page was displayed.
thanx!
alex