Skip to content

Commit

Permalink
Refs #332. Beginning fix for multiple session starts.
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed Mar 25, 2010
1 parent 4f4d3f9 commit d95e482
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions cake/libs/session.php
Expand Up @@ -116,6 +116,13 @@ class CakeSession extends Object {
* @access public * @access public
*/ */
var $id = null; var $id = null;
/**
* Session Started
*
* @var boolean
* @access public
*/
var $started = false;
/** /**
* Constructor. * Constructor.
* *
Expand Down Expand Up @@ -163,16 +170,19 @@ function __construct($base = null, $start = true) {
/** /**
* Starts the Session. * Starts the Session.
* *
* @param string $name Variable name to check for * @return boolean True if session was started
* @return boolean True if variable is there
* @access public * @access public
*/ */
function start() { function start() {
if ($this->started) {
return true;
}
if (function_exists('session_write_close')) { if (function_exists('session_write_close')) {
session_write_close(); session_write_close();
} }
$this->__initSession(); $this->__initSession();
return $this->__startSession(); $this->started = $this->__startSession();
return $this->started;
} }
/** /**
* Determine if Session has been started. * Determine if Session has been started.
Expand Down Expand Up @@ -475,12 +485,13 @@ function __initSession() {
ini_set('session.auto_start', 0); ini_set('session.auto_start', 0);
} }
} }
session_set_save_handler(array('CakeSession','__open'), session_set_save_handler(
array('CakeSession', '__close'), array('CakeSession','__open'),
array('CakeSession', '__read'), array('CakeSession', '__close'),
array('CakeSession', '__write'), array('CakeSession', '__read'),
array('CakeSession', '__destroy'), array('CakeSession', '__write'),
array('CakeSession', '__gc')); array('CakeSession', '__destroy'),
array('CakeSession', '__gc'));
break; break;
case 'php': case 'php':
if (empty($_SESSION)) { if (empty($_SESSION)) {
Expand All @@ -507,12 +518,13 @@ function __initSession() {
ini_set('session.cookie_path', $this->path); ini_set('session.cookie_path', $this->path);
} }
} }
session_set_save_handler(array('CakeSession','__open'), session_set_save_handler(
array('CakeSession', '__close'), array('CakeSession','__open'),
array('Cache', 'read'), array('CakeSession', '__close'),
array('Cache', 'write'), array('Cache', 'read'),
array('Cache', 'delete'), array('Cache', 'write'),
array('Cache', 'gc')); array('Cache', 'delete'),
array('Cache', 'gc'));
break; break;
default: default:
if (empty($_SESSION)) { if (empty($_SESSION)) {
Expand Down

0 comments on commit d95e482

Please sign in to comment.