Submit Your Article Forum Rules

Results 1 to 3 of 3

Thread: Die SESSION, Die! (PHP Problem)

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Posts
    9

    Die SESSION, Die! (PHP Problem)

    Hey folks, having a tough time with this one.

    Just finished launching a site with session handling for the shopping cart. Everything's peachy up to the actual order completion, because my session isn't being destroyed where I tell it to.

    You see, cart items are added to the order in the database, and to some degree it relies on the session id to differentiate. So when they reach the thank you page I destroy the session. But in some instances when people keep looking around, their session is gone but the session id is intact, so it totally screws up the order in the database!

    Any ideas? You will be saving me from much wailing and gnashing of teeth.

  2. #2
    You could use session_regenerate_id() to create a new session id value at the end of the checkout process.
    In the long run however I suggest making sure your shopping cart info persists even after the session has ended if the visitor did not complete the checkout process.
    Using a $_COOKIE variable along with the $_SESSION would offer an increase usability to your shopping cart.

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Posts
    9
    holyhttp: thanks for the advice. For some reason even that wasn't working, because we were in a secure area, whereas the session is created in a non-secure area. It was a weird fluke that I've never experienced before, but I think I figured it out.

    Because the orders are tied to the session_id, I could check if a completed order already existed with that session_id once the user got back to the cart. If so, then session_regenerate_id(). It works like a charm.

    I don't know if this will be any help to anyone in the future. I sure hope no one else has to deal with this.

Similar Threads

  1. Session Ids
    By Fort Worth Realtor in forum Search Engine Optimization Forum
    Replies: 5
    Last Post: 01-12-2007, 11:42 PM
  2. session problem:plz help
    By Informer45 in forum Web Programming Discussion Forum
    Replies: 2
    Last Post: 12-17-2004, 07:21 AM
  3. PHP Session control problem.
    By rodrigo in forum Web Programming Discussion Forum
    Replies: 6
    Last Post: 07-22-2004, 07:54 PM
  4. Regarding session ids
    By site-report in forum Search Engine Optimization Forum
    Replies: 2
    Last Post: 03-16-2004, 04:31 PM
  5. Your Session Suggestions Please
    By Garrett in forum Insider Reports
    Replies: 12
    Last Post: 12-09-2003, 10:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •