• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session not being destroyed upon the browser closure

#7
[eluser]Refringe[/eluser]
Great! It's working now.

What I've ended up doing is changing WanWizard's code so the $config['sess_expiration'] variable can still be used, however if the value is set to "0" then it's kept that way. A little more extendable that way, I think.

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    /*
    ** MY_Session Class
    **
    ** Extends the core CI_Session, giving default session behaviour;
    ** when the browser closes, the sessions are destroyed.
    */
    class MY_Session extends CI_Session {
        
        function MY_Session()
        {
            parent::CI_Session();
        }
        
        function _set_cookie($cookie_data = NULL)
        {
            if (is_null($cookie_data))
            {
                $cookie_data = $this->userdata;
            }
            $cookie_data = $this->_serialize($cookie_data);
            if ($this->sess_encrypt_cookie == TRUE)
            {
                $cookie_data = $this->CI->encrypt->encode($cookie_data);
            }
            else
            {
                $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key);
            }
            
            /*
            ** The only time $this->sess_expiration will be equal to this value is when
            ** $config['sess_expiration'] is set to "0". We're just making sure it
            ** stays this way.
            */
            if ($this->sess_expiration == 63072000)
            {
                $this->sess_expiration = 0;
            }
            else
            {
                $this->sess_expiration = $this->sess_expiration + time();
            }
            setcookie($this->sess_cookie_name, $cookie_data, $this->sess_expiration, $this->cookie_path, $this->cookie_domain, 0);
        }
    }
    
?>

Thanks for your help.


Messages In This Thread
Session not being destroyed upon the browser closure - by El Forum - 10-05-2009, 11:36 PM
Session not being destroyed upon the browser closure - by El Forum - 10-06-2009, 01:09 AM
Session not being destroyed upon the browser closure - by El Forum - 10-06-2009, 04:27 AM
Session not being destroyed upon the browser closure - by El Forum - 10-07-2009, 08:39 AM
Session not being destroyed upon the browser closure - by El Forum - 10-07-2009, 08:58 AM
Session not being destroyed upon the browser closure - by El Forum - 10-07-2009, 10:46 AM
Session not being destroyed upon the browser closure - by El Forum - 10-07-2009, 10:51 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.