RE: [PHP] Sessions: I don't get it!!

From: Date: Mon, 15 Nov 2004 11:02:29 +0000
Subject: RE: [PHP] Sessions: I don't get it!!
Groups: php.general 
Request: Send a blank email to php-general+get-202032@lists.php.net to get a copy of this message
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 15 November 2004 06:13, nate@savingadvice.com wrote: > Looks like you're making it way more complicated than it > needs to be. PHP > will automatically tack on the Session ID tag to your local > url's, but only > if it needs to. There is no need to append the SID to url's manually. Not to most URLs, no, but if the SID is being passed in the URL you *must* append it to any header("Location: ...") URL. Fortunately, this, too, is easy, and the OP was making it way more complicated than it needs to be! ;) The constant SID only contains the session name and id *when it needs to* -- otherwise it's defined as the empty string. So you can unconditionally append it to URLs and get the right result: header('Location: simple2.php?'.SID); The only tidying-up you might want to do, if you're really obsessional about neatness, is suppress the '?' if SID is empty, so: header('Location: simple2.php'.SID?('?'.SID):''); I can't see any benefit in applying strip_tags() to SID, unless you're terminally paranoid -- as it's generated internally by PHP, there shouldn't be any way it can contain anything that strip_tags() would defend against. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#202032) next »