lilywong Posted July 15, 2006 Share Posted July 15, 2006 I am doing a website something like online shopping system, anyone allows to browse my website and add cart (before log in), and the item added will be store using cookies, so user are allow to view their shopping basket even he has not log in yet.However, if a user finally decided to buy the selected item in the shopping basket, he will then need to log in, if he is a new user he will need to register, else just simply put his username and password. After log in, i decided to use Session to keep the user ID and selected item, is it possible to do that ? is it possible to use cookies to keep user preference before log in, and change to use Session to keep user preference after log in?I'm wondering, please advice. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/14655-php-cookies-problem/ Share on other sites More sharing options...
hvle Posted July 15, 2006 Share Posted July 15, 2006 yes, it's possible to use cookie to maintain user's references before login.cookies and session provided storage of data on client and server respectively. Quote Link to comment https://forums.phpfreaks.com/topic/14655-php-cookies-problem/#findComment-58471 Share on other sites More sharing options...
lilywong Posted July 15, 2006 Author Share Posted July 15, 2006 anyone can show a single example about capture a user preference using cookies?or any link i can see the source code for my references ?thank you so much ! Quote Link to comment https://forums.phpfreaks.com/topic/14655-php-cookies-problem/#findComment-58525 Share on other sites More sharing options...
hvle Posted July 16, 2006 Share Posted July 16, 2006 to set a cookie:setcookie ("TestCookie", $value, time()+3600); /* expire in 1 hour */to get the cookie:echo $_COOKIE["TestCookie"];you must do cookie setting before sending any header information Quote Link to comment https://forums.phpfreaks.com/topic/14655-php-cookies-problem/#findComment-58728 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.