CodeIgniter Forums
ionauth and shopping cart - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: ionauth and shopping cart (/showthread.php?tid=33345)



ionauth and shopping cart - El Forum - 08-23-2010

[eluser]martynrlee[/eluser]
Hi all,

I am integrating ionauth with the codeigniter cart, both are working great however if I have items in my cart then I login, I lose the cart items.

Guess this is session related, I have scanned the login scripts and doesnt seem to be ended the session and starting a new one, so I am a bit lost.

Fairly new to codeigniter, so if someone could point me in the right direction that would be great.

Thanks,

Martyn


ionauth and shopping cart - El Forum - 08-24-2010

[eluser]martynrlee[/eluser]
hmmm, anyone else have any advice?


ionauth and shopping cart - El Forum - 08-24-2010

[eluser]basementDUDE[/eluser]
I also use shopping cart and ion auth, I lose cart info when user logout.
Have not really looking into this issue yet, may we should post this issue on the ion auth post.


ionauth and shopping cart - El Forum - 08-24-2010

[eluser]WanWizard[/eluser]
This is a known issue with the way most users implement authentication.

Instead of having a proper data structure within the session to store user related information, and erasing/resetting that when a user logs out, they take the lazy option, and do a $this->session->sess_destroy(). That takes care of the logout, but also deletes all other valuable information in the session.

If you look in the Ion_auth library, in the logout() method, there a line that says
Code:
$this->ci->session->sess_destroy();

Comment this to retain your session. The unset_userdata() calls above that line will make sure the user is logged out.


ionauth and shopping cart - El Forum - 08-24-2010

[eluser]martynrlee[/eluser]
Thanks WanWizard, thats really useful.

Martyn.


ionauth and shopping cart - El Forum - 08-25-2010

[eluser]basementDUDE[/eluser]
what I don't understand is, the author already unset all the login data, why he still called sess_destory after that?

Code:
$identity = $this->ci->config->item('identity', 'ion_auth');
        $this->ci->session->unset_userdata($identity);
        $this->ci->session->unset_userdata('group');
        $this->ci->session->unset_userdata('id');
        $this->ci->session->unset_userdata('user_id');

[quote author="WanWizard" date="1282691783"]This is a known issue with the way most users implement authentication.

Instead of having a proper data structure within the session to store user related information, and erasing/resetting that when a user logs out, they take the lazy option, and do a $this->session->sess_destroy(). That takes care of the logout, but also deletes all other valuable information in the session.

If you look in the Ion_auth library, in the logout() method, there a line that says
Code:
$this->ci->session->sess_destroy();

Comment this to retain your session. The unset_userdata() calls above that line will make sure the user is logged out.[/quote]


ionauth and shopping cart - El Forum - 08-26-2010

[eluser]WanWizard[/eluser]
Seen that as well. I guess he wanted to be absolutely sure... Smile