0
votes

I am facing a big problem which is in the shopping cart !

I used this way to make my shopping cart system :

Click here to see the example

when I add a product to the shopping cart it adds it very well but the problem is in the session, it stores it in the server not in the client browser.

so if some body visit the website from another computer he can see the added products on his browser while it should be empty.

Is there a way to save it on the client side instead of the server side ??

2
Not by Session, I'd say either Javascript or cookies.Patryk Ćwiek
The session is identified by a session id and is bound to that id and will only be displayed to that session. If users share cart it's either not stored in the session or they get the same id. Posting the code that does. It work as intended is always a good ideaRune FS
can you show us how you are storing it in the session?Sleiman Jneidi
A session variable is supposed to be stored on the server. The only thing "stored" on the client is the session id. When someone request the site from another computer he is supposed to get another session id, with its own session variables.comecme

2 Answers

1
votes

Store an id of some kind in a cookie then when the visitor returns to the site check the cookie to see if it exists and if it does use the Id to retrieve the data required from the database.

0
votes

If I were buying something and I have to move to another computer, I would expect to see my cart with previous products in that computer too, and if I had to re-type everything, for sure I'll go to buy somewhere else..

Said that, you can use several methods to achieve your goal. Cookies, navigator LocalStorage, even a flash pluging.

I like very much this javascript library, which handles all this situation very well in a consistent manner:

http://pablotron.org/software/persist-js/

Best regards.