Jump to content

PHP Cookies problem


lilywong

Recommended Posts

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.