session question
Moderator: General Moderators
session question
Hi I'm kinda new at this but I am having some trouble with sessions. Lets say I have multiple shopping carts for customers and they go to one site to order something and then adds it to the cart (this is where the session starts) then goes back and if they go to another site and trys to order something else, in the other sites shopping cart it would show the variables from the first site in the shopping cart? My question is how can I differentiate or start a new session ID if they go to another site? because I am using the same code in each shopping cart. So if they were to go to one site and add things to that cart and not checkout yet......then goes to another site and adds things to that cart the items from the first cart is not added to the second cart. but then if they go back to the first their items are still there?? I hope that makes sense.....Any Help would be much appreicated....Thanks in Advance
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
http://tinyurl.com/2jzw8d might be of interest - it sounds like a lot of work, but could be worth it!
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I'm not sure if that will work for me........but i will try it. Lets say I start a session in the shopping cart and populate an array $cart and register that, go back to the website go to another site and add an item to the cart that will populate array $cart, won't that array have both items in it since I registered that array?
How do I keep the sessions separate so the array doesn't have both items....if that makes sense??
How do I keep the sessions separate so the array doesn't have both items....if that makes sense??
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Say you have four carts, one each for music, posters, books and shirts. Since each cart is on the same domain (unless you specify certain information for your session cookies using something like session_set_cookie_params() ) your cookie will reference one session. That is ok, as long as each cart is identified in your session array. Give each cart an identifier, then use that identifier when you are in that particular cart to keep track of things in that cart, so the carts don't mix.