Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Issue

Status
Not open for further replies.

GiffordS

Programmer
May 31, 2001
194
CA
Ok, this is making me crazy. I'm working on a site that uses sessions to track an order number. I register $ordernum and it persists throughout the users visit without fail or problem. Everything goes into and out of the cart based on $ordernum, all shipping info... everything without issue. The owner of the site uses PayPal, so once the customer decides to actually pay they are taken to PayPal to pay and then returned to a final page on the site, complete.php. It is on this page that I change the order status to paid, update inventory, and send out confirmation emails. For some strange reason when the customer is taken back to complete.php $ordernum, indeed the entire session, is gone. It's maddening. It can't be a problem with PayPal per se, because I can cut off in the middle of an order, go to PayPal, go pretty much anywhere, and come back to the site and the session is still running and $ordernum is still registered. On the other hand, if I skip paypal and manually go to complete.php from say, the view cart page it pulls up $ordernum just fine. I am completely at a loss on this one. Any thoughts.

FWIW, I can't really post reams of code here but I can assure you that Session_start(); is the first line of code on every page of the site.
 
Your session ends when the user leaves your site. This is why when you manually do it it works, you never leave the site.
 
I can cut off in the middle of an order, go to PayPal, go pretty much anywhere, and come back to the site and the session is still running...
When you say "come back", is that by the Back button? If you come back via a bookmark to the e-store's top page or something, does it still work okay? If not, then my second question is: are you allowing cookies in your browser or not?

In my understanding of sessions, if it's using a cookie to pass the session ID, you should be able to go to other sites, as long as you keep the browser open, and your session will be intact. But if you have disabled cookies, PHP has to pass your session ID from page to page via the URL. In that case, if you go elsewhere and then come back by any other method other than the Back button, since the other site will not continue dropping bread crumbs for you, you'll have lost your session ID, and therefore your session. Does that fit your situation?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top