public static function init($longlastingsession = false)
{
//check if session name is correct
- if ( session_id() && session_id()!=self::$sessionName ) {
+ if ( (session_id() && !empty(self::$sessionName) && session_name()!=self::$sessionName) || $longlastingsession ) {
session_destroy();
}
}
if ( $longlastingsession ) {
- session_set_cookie_params(self::$longSessionTimeout, $cookiedir, $_SERVER['HTTP_HOST'], $ssl, true);
+ session_set_cookie_params(self::$longSessionTimeout, $cookiedir, null, $ssl, true);
}
else {
- session_set_cookie_params('', $cookiedir, $_SERVER['HTTP_HOST'], $ssl, true);
+ session_set_cookie_params(0, $cookiedir, null, $ssl, true);
}
//set server side valid session timeout
//WARNING! this may not work in shared session environment. See http://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime about min value: it can be set in any application
|| (self::$disableSessionProtection === false
&& $_SESSION['ip'] !== self::_allIPs())
|| time() >= $_SESSION['expires_on']) {
- self::logout();
+ //self::logout();
return false;
}
return true; // User is not banned.
}
+
+
+ /**
+ * Tells if a param exists in session
+ *
+ * @param $name name of the param to test
+ * @return bool
+ */
+ public static function isInSession($name)
+ {
+ return (isset($_SESSION[$name]) ? : FALSE);
+ }
+
+ /**
+ * Returns param in session
+ *
+ * @param $name name of the param to return
+ * @return mixed param or null
+ */
+ public static function getParam($name)
+ {
+ return (self::isInSession($name) ? $_SESSION[$name] : NULL);
+ }
+
+ /**
+ * Store value in session
+ *
+ * @param $name name of the variable to store
+ * @param $value value to store
+ */
+ public static function setParam($name, $value)
+ {
+ $_SESSION[$name] = $value;
+ }
}