Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep session data using Codeigniter and Tank Auth

I'm using Codeigniter and Tank Auth for a e-commerce website. I'm finding that if a customer puts items into the cart (using the Codeigniter built in cart class) and then registers on the site the session is lost along with their cart (I'm presuming it generates a new session for some reason instead of keeping the same session).

Has anyone come across this problem before? and is there a simply solution that I have overlooked.

Thanks

like image 734
BlueFox Avatar asked Oct 24 '22 12:10

BlueFox


1 Answers

As far as the most recent code looks like, the only place the hole session is deleted is in the logout() function, Tank_auth.php Line 118: https://github.com/ilkon/Tank-Auth/blob/master/application/libraries/Tank_auth.php#L118

The example usage of Tank Auth uses logout() in activate() and reset_email() - check your code for those methods. You could also change the Tank Auth logout function to something like this:

function logout($keep_session = false)
{
    $this->delete_autologin();

    // See http://codeigniter.com/forums/viewreply/662369/ as the reason for the next line
    $this->ci->session->set_userdata(array('user_id' => '', 'username' => '', 'status' => ''));

    if(!$keep_session)
        $this->ci->session->sess_destroy();
}

... and the use it like this: $this->tankauth->logout(true);

like image 83
Ruben Müller Avatar answered Oct 27 '22 10:10

Ruben Müller