Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 977
  • Last Modified:

session id / anonymous id to save shopping cart

I want to be able to save the shoppping cart even whether the user is logged in to the website or not. how can I associate the shopping cart to the user when the user is not logged in.

If I use the session ID can I still acess the same session ID, even if the user closes there browser and re-opens after a few days?

Should I be using the anonymous ID for this purpose instead of session ID. Thank
0
TrialUser
Asked:
TrialUser
  • 2
  • 2
4 Solutions
 
Daniel Van Der WerkenCommented:
I would use something like the client's IP address to use as the "anonymous ID" for the user.  You can get it with this:

HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

Then, save this out in a Cookie.  Sessions won't last but Cookies will.

0
 
Richard LeeSoftware EnthusiastCommented:
Simply save the shopping cart details in a cookie if the user is not logged in and to make the user really happy, merge the contents of the cookie with their existing basket contents after offering them the option.

DaTribe
0
 
TrialUserAuthor Commented:
Ok, instead of writin g to a cookie can I write into the database? I am wondering if we can loose the information stored in the cookie based on the users browser settings. Thanks
0
 
Richard LeeSoftware EnthusiastCommented:
No doubt you can lose the information in a cookie based on the user settings and also if they love clearing their cookies. The database would be a great solution - like what amazon does.

DaTribe
0
 
TrialUserAuthor Commented:
thx
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now