[pLog-svn] r1944 - plog/branches/plog-1.0.1/class/net/http/session
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Thu May 5 19:26:13 GMT 2005
Author: oscar
Date: 2005-05-05 19:26:13 +0000 (Thu, 05 May 2005)
New Revision: 1944
Modified:
plog/branches/plog-1.0.1/class/net/http/session/sessionmanager.class.php
Log:
core change: added methods for easily setting and retrieving data from the session
Modified: plog/branches/plog-1.0.1/class/net/http/session/sessionmanager.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/net/http/session/sessionmanager.class.php 2005-05-05 18:09:12 UTC (rev 1943)
+++ plog/branches/plog-1.0.1/class/net/http/session/sessionmanager.class.php 2005-05-05 19:26:13 UTC (rev 1944)
@@ -6,6 +6,8 @@
include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
include_once( PLOG_CLASS_PATH."class/net/url.class.php" );
+ $__sessionManagerInitialized = false;
+
/**
* \ingroup Net_HTTP
*
@@ -45,7 +47,11 @@
if( !array_key_exists("SessionInfo", $session) || $session["SessionInfo"] == "" ) {
$session["SessionInfo"] = new SessionInfo();
HttpVars::setSession( $session );
- }
+ }
+
+ // inform the other methods that the session manager has already been intialized
+ global $__sessionManagerInitialized;
+ $__sessionManagerInitialized = true;
}
/**
@@ -133,5 +139,59 @@
return true;
}
+
+ /**
+ * return the value of a parameter from the session
+ *
+ * @param key The name of the parameter
+ * @return The value assigned to this key
+ */
+ function getSessionValue( $key )
+ {
+ // switch that informs whether the session manager has already been initialized or not
+ global $__sessionManagerInitialized;
+
+ // check if the session manager has already been initialized
+ if( !$__sessionManagerInitialized ) {
+ throw( new Exception( "SessionManager::init() must be called before SessionManager::getSessionValue()" ));
+ die();
+ }
+
+ // get the session and SessionInfo object
+ $session = HttpVars::getSession();
+ $sessionInfo = $session["SessionInfo"];
+
+ // and now return the value
+ return( $sessionInfo->getValue( $key ));
+ }
+
+ /**
+ * sets a value in the session
+ *
+ * @param key the key assigned to this vlaue
+ * @param value The value assigned
+ * @return always true
+ */
+ function setSessionValue( $key, $value )
+ {
+ // switch that informs whether the session manager has already been initialized or not
+ global $__sessionManagerInitialized;
+
+ // check if the session manager has already been initialized
+ if( !$__sessionManagerInitialized ) {
+ throw( new Exception( "SessionManager::init() must be called before SessionManager::getSessionValue()" ));
+ die();
+ }
+
+ // get the session and SessionInfo object
+ $session = HttpVars::getSession();
+ $sessionInfo = $session["SessionInfo"];
+ // set the value and save it to the session
+ $sessionInfo->setValue( $key, $value );
+ $session["SessionInfo"] = $sessionInfo;
+ HttpVars::setSession( $session );
+
+ return true;
+ }
}
?>
More information about the pLog-svn
mailing list