Skip to content

Commit

Permalink
don't write a cookie when we just read one. closes #72
Browse files Browse the repository at this point in the history
  • Loading branch information
daaku committed May 8, 2010
1 parent 2ec20bb commit b9d08a1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,16 @@ public function getBaseDomain() {
* Set the Session.
*
* @param Array $session the session
* @param Boolean $write_cookie indicate if a cookie should be written. this
* value is ignored if cookie support has been disabled.
*/
public function setSession($session=null) {
public function setSession($session=null, $write_cookie=true) {
$session = $this->validateSessionObject($session);
$this->sessionLoaded = true;
$this->session = $session;
$this->setCookieFromSession($session);
if ($write_cookie) {
$this->setCookieFromSession($session);
}
return $this;
}

Expand All @@ -254,6 +258,7 @@ public function setSession($session=null) {
public function getSession() {
if (!$this->sessionLoaded) {
$session = null;
$write_cookie = true;

// try loading session from $_GET
if (isset($_GET['session'])) {
Expand All @@ -278,10 +283,12 @@ public function getSession() {
'"'
), $session);
$session = $this->validateSessionObject($session);
// write only if we need to delete a invalid session cookie
$write_cookie = empty($session);
}
}

$this->setSession($session);
$this->setSession($session, $write_cookie);
}

return $this->session;
Expand Down

0 comments on commit b9d08a1

Please sign in to comment.