Revision: 2190
Author: olavmrk
Date: Wed Feb 24 01:52:55 2010
Log: Session: Use transient session if headers are already sent.
http://code.google.com/p/simplesamlphp/source/detail?r=2190
Modified:
/trunk/lib/SimpleSAML/Session.php
/trunk/lib/SimpleSAML/SessionHandlerCookie.php
/trunk/lib/SimpleSAML/SessionHandlerPHP.php
=======================================
--- /trunk/lib/SimpleSAML/Session.php Wed Feb 24 01:52:44 2010
+++ /trunk/lib/SimpleSAML/Session.php Wed Feb 24 01:52:55 2010
@@ -142,7 +142,14 @@
/* Check if we have stored a session stored with the session
* handler.
*/
- self::$instance = self::loadSession();
+ try {
+ self::$instance = self::loadSession();
+ } catch (Exception $e) {
+ /* For some reason, we were unable to initialize this session. Use a
transient session instead. */
+ self::useTransientSession();
+ return self::$instance;
+ }
+
if(self::$instance !== NULL) {
return self::$instance;
}
=======================================
--- /trunk/lib/SimpleSAML/SessionHandlerCookie.php Mon Feb 15 01:46:55 2010
+++ /trunk/lib/SimpleSAML/SessionHandlerCookie.php Wed Feb 24 01:52:55 2010
@@ -35,6 +35,12 @@
if(array_key_exists('SimpleSAMLSessionID', $_COOKIE)) {
$this->session_id = $_COOKIE['SimpleSAMLSessionID'];
}
+
+ /* We need to create a new session. */
+
+ if (headers_sent()) {
+ throw new SimpleSAML_Error_Exception('Cannot create new session -
headers already sent.');
+ }
/* Check if we have a valid session id. */
if(self::isValidSessionID($this->session_id)) {
=======================================
--- /trunk/lib/SimpleSAML/SessionHandlerPHP.php Mon Feb 15 01:46:55 2010
+++ /trunk/lib/SimpleSAML/SessionHandlerPHP.php Wed Feb 24 01:52:55 2010
@@ -46,6 +46,11 @@
}
if(!array_key_exists(session_name(), $_COOKIE)) {
+
+ if (headers_sent()) {
+ throw new SimpleSAML_Error_Exception('Cannot create new session -
headers already sent.');
+ }
+
/* Session cookie unset - session id not set. Generate new (secure)
session id. */
session_id(SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(16)));
}
--
You received this message because you are subscribed to the Google Groups
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simplesamlphp-commits?hl=en.