Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extracting information from cookies

Status
Not open for further replies.

Dynamo3209

Programmer
Joined
Jan 2, 2003
Messages
57
Location
US
Hi,
I am developing an e-commerce site. I am putting all the items purchased by the customer into a cookie, now on the chekout page I want to display all the items selected for purchase by the customer, how can I extract this info from the cookie.

Thanks,
Dynamo.
 
print_r($_COOKIE);

will show you everything you saved.

Might I suggest looking into SESSION variables though? Not everyone has cookies enabled, and they'll be able to tinker with what you've put in the cookie.


-Rob
 
Just a note:
If they don't have cookies enabled you'd have to use a special case of sessions, since standard PHP sessions operate with a cookie also. It is, however, much smaller and only holds a unique reference ID for the data which will be temporarily stored on the server.
 
1. Cookies only store up to about 4k
2. Don't put stuff into cookies !, what I mean is use the php session id as a key into a db (such as mysql) and put any stuff in there. I know this adds complexity as you will to have housekeep this table but it is safer. Unless the cookie is encrypted you can look at it anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top