[SOLVED] 'Blank' Sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Klyve1
Forum Newbie
Posts: 14
Joined: Wed Sep 18, 2002 4:27 am
Location: Hove, UK

'Blank' Sessions

Post by Klyve1 »

I use sessions to identify customers as part of a shopping cart and have found on numerous occasions that no session id is picked up by $PHPSESSID.

Does anyone know why this is and how to fix it/work-around.
Thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

echo SID;
I'll have a look at your code if you send the relevant bits :-)
User avatar
Klyve1
Forum Newbie
Posts: 14
Joined: Wed Sep 18, 2002 4:27 am
Location: Hove, UK

Post by Klyve1 »

I'm using

session_start();

on all pages and $PHPSESSID to pick it up. This works 99.9% of the time but there's the odd one slipping through.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The correct way to do it is to use SID instead of $PHPSESSID (that's what goes in the URL by default). Try your code with cookies disabled in your browser and see if it works then let us know what happens. :-D
User avatar
Klyve1
Forum Newbie
Posts: 14
Joined: Wed Sep 18, 2002 4:27 am
Location: Hove, UK

Post by Klyve1 »

I'm not using id's as part of the url string, (and don't want to either) does this make any difference
User avatar
Klyve1
Forum Newbie
Posts: 14
Joined: Wed Sep 18, 2002 4:27 am
Location: Hove, UK

Post by Klyve1 »

Thanks for your help, I've now fixed the issue

I've added the following:

Code: Select all

<?php
if (!$PHPSESSID) { $PHPSESSID = session_id();}
?>
Post Reply