Welcome Guest, Not a member yet? Register   Sign In
cart and session class just don't like each other :(
#1

[eluser]basementDUDE[/eluser]
hey guys

I have set the "sess_expiration" in the config file to 0(never expire) in order to remember what items are in user's cart(I use CI cart class).

Now I want to use session to remember user's info(such as email, name, address etc) for create a user acct, but since I set the session never expire, it will also remember everything, and I think that creates some security issues.

If I destroy session, I also destroy cart
If I keep CI cart, I also have to keep the session data Sad

I am really stuck.

my bad solutiuon will be:
I have to ditch CI cart class and use cookie to store items and set cookie never expire, then i can use native php session to store user data, but in order to do that I have to modify lots of code Sad.


Is there a easy way to clear session data but keeps CI cart untouched when browser close?
(I prefer not to modify session class, since I am a noob)

thanks a lot
#2

[eluser]skunkbad[/eluser]
Why not just use a second cookie?

http://ellislab.com/codeigniter/user-guide/helpers/cookie_helper.html
#3

[eluser]basementDUDE[/eluser]
you mean store user data on the second cookie instead of session?

[quote author="skunkbad" date="1280208589"]Why not just use a second cookie?

http://ellislab.com/codeigniter/user-guide/helpers/cookie_helper.html[/quote]
#4

[eluser]Jelmer[/eluser]
Maybe a cleanup function that does $this->session->unset_userdata() on all the fields you want removed after a while? Instead of doing a full $this->session->sess_destroy().
#5

[eluser]basementDUDE[/eluser]
good idea.
however, I have a problem with it.
I only need to call sess_destroy() when user finish order or empty their cart. so, just 2 place I need to call this function.

If I use your idea then I have to call unset_userdata() in all functions of any controller in order to detect whether user is expired. Maybe I am wrong.


[quote author="Jelmer" date="1280211619"]Maybe a cleanup function that does $this->session->unset_userdata() on all the fields you want removed after a while? Instead of doing a full $this->session->sess_destroy().[/quote]
#6

[eluser]skunkbad[/eluser]
[quote author="basementDUDE" date="1280210433"]you mean store user data on the second cookie instead of session?

[quote author="skunkbad" date="1280208589"]Why not just use a second cookie?

http://ellislab.com/codeigniter/user-guide/helpers/cookie_helper.html[/quote][/quote]

Yes, then you can just unset the second cookie.
#7

[eluser]basementDUDE[/eluser]
but I need to unset the second cookie upon browser close?
maybe that's impossible.


[quote author="skunkbad" date="1280214082"][quote author="basementDUDE" date="1280210433"]you mean store user data on the second cookie instead of session?

[quote author="skunkbad" date="1280208589"]Why not just use a second cookie?

http://ellislab.com/codeigniter/user-guide/helpers/cookie_helper.html[/quote][/quote]

Yes, then you can just unset the second cookie.[/quote]
#8

[eluser]skunkbad[/eluser]
From the user manual:

The expiration is set in seconds, which will be added to the current time. Do not include the time, but rather only the number of seconds from now that you wish the cookie to be valid. If the expiration is set to zero the cookie will only last as long as the browser is open.
#9

[eluser]Zeeshan Rasool[/eluser]
Actualluy, I face many times session problem in CI and I posted here too. PHP errors, bugs or even warnings lost session and doesnt save any thing.
In your case, I totally areed with Jelmer suggestion.




Theme © iAndrew 2016 - Forum software by © MyBB