pugboy Posted July 9, 2008 Share Posted July 9, 2008 I am making a shopping cart in PHP (not using real currency), and need to store the cart in a cookie. The best way is an array. Can I use count($_COOKIE["cart"]) if the cart cookie was set up so item one was stored as a cookie with the name cart[0]? Quote Link to comment https://forums.phpfreaks.com/topic/114003-solved-cookie-arrays/ Share on other sites More sharing options...
ShimmyShine Posted July 9, 2008 Share Posted July 9, 2008 Can't people modify cookies? I am not 100% sure i havn't looked into them. But it would be simpler to use a database yeah? Shimmy Quote Link to comment https://forums.phpfreaks.com/topic/114003-solved-cookie-arrays/#findComment-585923 Share on other sites More sharing options...
trq Posted July 9, 2008 Share Posted July 9, 2008 Can I use count($_COOKIE["cart"]) if the cart cookie was set up so item one was stored as a cookie with the name cart[0]? Pardon? Quote Link to comment https://forums.phpfreaks.com/topic/114003-solved-cookie-arrays/#findComment-585925 Share on other sites More sharing options...
pugboy Posted July 9, 2008 Author Share Posted July 9, 2008 Can I use: count($_COOKIE["cart"]) to get the size of the cookie array? I added the array elements using the cookie name cart[NUMBER] And also, it is just the shopping cart that is being stored in cookies. The shop item IDs and stuff are in the DB Quote Link to comment https://forums.phpfreaks.com/topic/114003-solved-cookie-arrays/#findComment-585926 Share on other sites More sharing options...
trq Posted July 9, 2008 Share Posted July 9, 2008 Yes, count returns the size of an array. Maybe you need to use recursion though? count($_COOKIE["cart"],1) Who knows? Quote Link to comment https://forums.phpfreaks.com/topic/114003-solved-cookie-arrays/#findComment-585928 Share on other sites More sharing options...
pugboy Posted July 10, 2008 Author Share Posted July 10, 2008 Ok, it work Quote Link to comment https://forums.phpfreaks.com/topic/114003-solved-cookie-arrays/#findComment-585936 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.