On Apr 17, 2011, at 01:03, Greg Skerman wrote: > Basically I want to be able to store the cake Session token in a cookie, then > wake the session matching that cookie back up on a subsequent visit. > > Imagine the following scenario (not precisely what I'm doing, but a good > illustration none the less). > > User visits an online store, and puts a bunch of items in their shopping cart. > User then decides to leave the store, without going through the checkout > Weeks later, the user revisits the store > > I want to be able to grab the shopping basket that the user had already > filled (stored in the session when the visited), and wake the session back up > so they don't have to go and fill their basket back up with stuff again. > > I get that I have to somehow store the session token in a cookie, but how do > i wake expired sessions back up so that the state matches what it was when > they left the store in the first place?
Session ids are already stored as a cookie. That's standard PHP, and CakePHP uses it too. That's not the problem. The problem is sessions are temporary. Depending on the settings in your php.ini, a session might only last 20 minutes for example. You can change the session lifetime, but you probably don't want to increase it very much (certainly not more than a day, usually much less than that) since, depending on how busy your site is, you'll quickly end up with tons of sessions lying around taking up disk space that aren't actually being used by anyone. You could store the cart in your database in some tables of your own creation. Store that with the user id so you can bring it back when the user logs in again. If you're allowing unregistered (or not-logged-in) users to put things in a cart, and you want to save those too, then you'll probably have to store the cart based on some unique id you invent, and store that unique id in a longer-lived cookie. Then again, you're running into the same problem as a longer-lived session... -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
