PHP $_SESSION Question

Thinking of using session variables for a shopping cart

Page 1 of 1

4 Replies - 600 Views - Last Post: 22 March 2010 - 01:16 AM Rate Topic: -----

#1 Moshambi  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 280
  • Joined: 20-November 07

PHP $_SESSION Question

Posted 22 March 2010 - 01:06 AM

Hello,

So I am looking to create a simple shopping cart that is only able to be viewed before checkout. I was thinking of using a $_SESSION variable to do this like $_SESSION['shoppingCart] = array(); then adding each item to the shopping cart array. Now my question is this: if I were to do it this way would each persons session variable be unique to themselves (there is no login required for this)?

Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: PHP $_SESSION Question

#2 Xuhybrid  Icon User is offline

  • D.I.C Head

Reputation: 30
  • View blog
  • Posts: 106
  • Joined: 20-January 10

Re: PHP $_SESSION Question

Posted 22 March 2010 - 01:10 AM

Only until they log out or close the browser. You would need to store it in a database if it needed to be permanently stored. I advise against using Cookies, if that was your alternative.

This post has been edited by Xuhybrid: 22 March 2010 - 01:10 AM

Was This Post Helpful? 1
  • +
  • -

#3 Moshambi  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 280
  • Joined: 20-November 07

Re: PHP $_SESSION Question

Posted 22 March 2010 - 01:12 AM

By logout you mean leave the site, close the browser, etc? Because there is no user login so I am just curious to know if everyone that is on the site will be using the same session variable or if it is unique to each persons own browser/browsing session. I do not need to store the information permanently but just for the time the user is at the site.

Thank you for the quick response.
Was This Post Helpful? 0
  • +
  • -

#4 Xuhybrid  Icon User is offline

  • D.I.C Head

Reputation: 30
  • View blog
  • Posts: 106
  • Joined: 20-January 10

Re: PHP $_SESSION Question

Posted 22 March 2010 - 01:14 AM

Yes, sry i edited my post to say or browser. The session would be the best option, it will be unique to each browser and computer.
Was This Post Helpful? 2
  • +
  • -

#5 Moshambi  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 280
  • Joined: 20-November 07

Re: PHP $_SESSION Question

Posted 22 March 2010 - 01:16 AM

Awesome. Thank you so much for your help and especially the quick responses!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1