Sessions and W3C standards compliance

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
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Sessions and W3C standards compliance

Post by uberpolak »

Here's the situation, I use session variables to remember which stylesheet a user has selected, and if no session already exists, the server adds "?PHPSESSID=(id)" to the ends of all my links. The problem occurs when the link already has a variable in it, and becomes something like this:

page.php?p=home&PHPSESSID=(id)

The "&" character is illegal in XHTML1.1, and this causes my pages not to validate. Does anybody know a way to change what the server inserts on the links?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

There is a setting in the php.ini which governs what URL variable separators are. From a bit of digging on the site, this appears to be arg_separator:
http://php.net/manual/en/configuration. ... tor.output
There's a bit about it on this page (scroll down to the bit about 'Passing the Session ID'):
http://php.net/session

HTH,
Mac
niceguyeddie
Forum Newbie
Posts: 13
Joined: Fri Nov 28, 2003 7:12 am
Location: Westminster, MD

Post by niceguyeddie »

I had the same problem and there are a couple of ways to go about it. The easiest is to do a htaccess, rather than hack your script, IMO.

Here's a useful tutorial that I have found:

http://martin.f2o.org/php/session
Post Reply