Page 1 of 1
session question
Posted: Wed May 09, 2007 4:28 pm
by apdragon
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
Posted: Wed May 09, 2007 5:31 pm
by Kieran Huggins
You're trying to bridge shopping carts between two sites you run? Are they on the same server?
Posted: Thu May 10, 2007 1:40 am
by dibyendrah
It's kinda tricky. Yes, if the both site runs on the same server, then it might open a possibility for doing something like that.
Posted: Thu May 10, 2007 4:43 am
by Kieran Huggins
http://tinyurl.com/2jzw8d might be of interest - it sounds like a lot of work, but could be worth it!
Posted: Thu May 10, 2007 10:28 am
by apdragon
I'm not trying to bridge shopping carts.....but keep them seperated so one person can't order from another site. Thats why I was thinking of having a unique session ID?
Posted: Thu May 10, 2007 11:10 am
by RobertGonzalez
Are the shopping carts on the same domain?
Posted: Thu May 10, 2007 11:53 am
by apdragon
yes they are
Posted: Thu May 10, 2007 12:09 pm
by RobertGonzalez
You're cookies are going to be transposed I believe, since the sessions are happening on the same domain. You might consider setting a session variable with an ID of the shopping cart so you always know which one you are in.
Posted: Thu May 10, 2007 3:46 pm
by apdragon
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??
Posted: Thu May 10, 2007 3:59 pm
by RobertGonzalez
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.