PHP5 dropping sessions

software development

#1

I wrote a shopping cart script and for no reason that I can discern, the session will spontaneously drop between the view cart and the checkout page. I wasn’t using the xhtml transitional doctype.

The actual site is http://clientdev1.crimsondryad.com. You can follow the path through to the payment page without affecting anything. The user can go through, shop, and hit the checkout page, which is where the session appears to be dropping. On the review order page, I do a check for the number of items in the session and output a “There are no items in your cart message” if it doesn’t exist. This only seems to happen on this one page.

I tried adding a session save path. The session is saved, but with no data. How would I go about forcing the session to write out and how would I retrieve it? I’m using POSTed form fields, so passing the session id via the URL really isn’t feasible here.

I also did some reading online and the php.net site says there was a problem with session handling in 5.1.2. The newest release is 5.1.4. I suppose it’s too much to ask that PHP get updated after all the craziness of the last week (with the power outage and related issues).

I’d appreciate the help on this one, I’m confused and my client is getting antsy. :slight_smile:

Angela

================================
Angela Gann
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com


#2

http://I’m using POSTed form fields, so passing the session id via the URL really isn’t feasible here.

The session id is supposed to be passed as a form field, right? Well have you checked to make sure the session id is there or not? This is what I see:

:cool: [color=#6600CC]Atropos[/color] | openvein.org


#3

No, I’m sorry for confusing you. I started to put that in there earlier until I realized that I’m passing it as a POST and everything I’ve read about sessions says I have to pass it url encoded (which I’m assuming is a GET).

The only reason I was even considering passing it that way was because the session is dropping. I’d really rather not pass the session ID in the URL at all, I’m just stumped for how else to get it to work at the moment.

================================
Angela Gann
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com


#4

I’m trying to hit that URL ya posted and keep getting a “Could not connect”; dunno what that’s all about (dead server??).
Anyways, I’ll try later - in the meanwhiles, can you temporarily pop this code: print "<!-- SID = ".SID." -->\r"; print "<!-- \$_SERVER "; print_r($_SERVER); print " -->\r"; print "<!-- \$_ENV "; print_r($_ENV); print " -->\r"; print "<!-- \$_SESSION "; print_r($_SESSION); print " -->\r"; print "<!-- \$_COOKIE "; print_r($_COOKIE); print " -->\r"; print "<!-- \$_REQUEST "; print_r($_REQUEST); print " -->\r"; print "<!-- \$_POST "; print_r($_POST); print " -->\r";…at the top of each of the pages in the transition (if ya don’t already have something like that in there)? Might help a bit.


#5

That’s a great snippet that I can never seem to find (and am ususally too lazy, tired, frustrated, to write) whenever I need it. clipped, and thanks!
–rlparker


#6

Thanks - but really, I need it just to catch my own typos most of the time. :slight_smile:
Just a small bit of what I put in my “init.php” file that gets included in every one of my PHP pages.


#7

Yes, my server has been wonky. In fact, ALL the servers I’m on have been wonky. Prolly what happened is when they shut down the generators the circuits on the servers contracted as they cooled and didn’t come back up properly when the power was restored.

In any case, I’m in the process of moving onto a dedicated server with another webhost as we speak. I’ll still be on here from time to time because I’ve got domains and such hosted (and because I like the company), but my clients are having kittens. I just can’t go without my email and sites not working properly anymore.

I hate to do it. I liked dreamhost for a long time. And it’s such a blasted pain in the rear to migrate everything. sigh

That is a really great snippet, I’ll try it. Though I suspect that turning on --enable trans-sid on the new server will fix it.

================================
Angela Gann
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com