HTTP_Session2: Ending it properly..
| From: | Louie Miranda | Date: | Fri, 24 Nov 2006 07:45:13 +0000 |
| Subject: | HTTP_Session2: Ending it properly.. | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-25914@lists.php.net to get a copy of this message | ||
I made a PHP Application that uses HTTP_Session2 (PHP5).
Its an ordering system..
Files are:
includes/order_sess.php
process.php
Under: includes/order_sess.php
<?php
require_once("PEAR.php");
require_once("HTTP/Session2.php");
HTTP_Session2::start();
HTTP_Session2::setExpire(time() + 90 * 60); // expires in one hour - time()
+ 60 * 60
HTTP_Session2::setIdle(60 * 60); // idles seconds 30 x 60 = 1800echo("------------------------------------------------------------------<br>\n"); echo("Session name: <b>'" . HTTP_Session2::name() . "'</b><br>\n"); echo("Session id: <b>'" . HTTP_Session2::id() . "'</b><br>\n"); echo("Is new session: <b>'" . (HTTP_Session2::isNew() ? "<span style='color: red;'>yes</span>" : "no") . "'</b><br>\n"); echo("Is expired: <b>'" . (HTTP_Session2::isExpired() ? "<span style='color: red;'>yes</span>" : "no") . "'</b><br>\n"); echo("Is idle: <b>'" . (HTTP_Session2::isIdle() ? "<span style='color: red;'>yes</span>" : "no") . "'</b><br>\n"); echo("Variable: <b>'" . HTTP_Session2::get('variable') . "'</b><br>\n"); echo("Session valid thru: <b>'" . (HTTP_Session2::sessionValidThru() - time()) . "'</b><br>\n"); echo("------------------------------------------------------------------<br>\n"); ?> On this file i only start and set the expiration and idle time. And i do the rest on each files. Under: process.php .. if (HTTP_Session2::isExpired()) // check for expired session {
echo "expired|||";
print("Session Expired, <a href=cart>click here to refresh your
session and go back to cart</a>");
HTTP_Session2::destroy();
exit;
}
elseif (HTTP_Session2::isIdle()) // check for idle session{
echo "idle|||";
print("Session has been idle for too long, <a href=cart>click here
to refresh your session and go back to cart</a>");
HTTP_Session2::destroy();
exit;
}
else // continue working again{ echo "not yet|||"; switch($_GET["action"]) { case "OrderProcessing": {
OrderProcessing();
}
};
HTTP_Session2::destroy();
HTTP_Session2::clear();
exit;
}; // end of session checking
..
NOW, my problem is when ever i tried to expire my application process.phpusing
HTTP_Session2::destroy(); and i tried to reload the browser, it bypass
detection of
if (HTTP_Session2::isExpired()) // check for expired session
elseif (HTTP_Session2::isIdle()) // check for idle sessionAnd therefore i could not show them and end the session properly, Im ending their session to prevent double post. Which i could not do. Im thingking that if i destroy the session on the lower part of the code, then after a user reloads the browser it will detect that it is expired and will show the expired message. But, its not. I think i am missing something here, please help! -- Louie Miranda (lmiranda@gmail.com) http://www.axishift.com //JSM-W