Page 1 of 1

how do i save a session variable just as the user is exiting

Posted: Thu Feb 10, 2011 1:21 pm
by Yko
Hi,

Suppose I have an ecommerce website like amazon and I would like to keep track of the items that the user is looking at. I can store it in a session but i would like to save it to the database when the user quits her browser. This is only to be done when the user logs in and so I am also wondering if there is a good way to keep a session variable in sync with a database table.

I can skip the $session if the user is logged in and save it directly to the db but I want it to work both when the user logs in and not. But, when the user logs in, the db history list is synced to the $session var.

I hope it makes sense.

Thanks.

Re: how do i save a session variable just as the user is exi

Posted: Thu Feb 10, 2011 2:38 pm
by MindOverBody
Just make logout function and in it store all session data to database. Same data load up on login.