Skip to content

Commit

Permalink
The stop method will now also delete the related cookie, if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
stefangabos committed Apr 19, 2017
1 parent 7805840 commit 39ea7c9
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Zebra_Session.php
Expand Up @@ -34,8 +34,7 @@
* @package Zebra_Session
*/

class Zebra_Session
{
class Zebra_Session {

private $flashdata;
private $flashdata_varname;
Expand Down Expand Up @@ -613,7 +612,10 @@ public function set_flashdata($name, $value) {
}

/**
* Deletes all data related to the session
* Deletes all data related to the session.
*
* <i>This method runs the garbage collector respecting your environment's garbage collector-related properties.
* Read {@link __construct() here} for more information.</i>
*
* <code>
* // first, connect to a database containing the sessions table
Expand All @@ -635,6 +637,18 @@ public function set_flashdata($name, $value) {
*/
public function stop() {

// if a cookie is used to pass the session id
if (ini_get('session.use_cookies')) {

// get session cookie's properties
$params = session_get_cookie_params();

// unset the cookie
setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);

}

// destroy the session
session_unset();
session_destroy();

Expand Down Expand Up @@ -683,7 +697,7 @@ function write($session_id, $session_data) {
*
* @access private
*/
function _manage_flashdata() {
private function _manage_flashdata() {

// if there is flashdata to be handled
if (!empty($this->flashdata)) {
Expand Down

0 comments on commit 39ea7c9

Please sign in to comment.