note 57868 added to faq.html

From: Date: Mon, 17 Oct 2005 13:31:51 +0000
Subject: note 57868 added to faq.html
Groups: php.notes 
Request: Send a blank email to php-notes+get-97116@lists.php.net to get a copy of this message
A Hiccup with PHP Sessions and the W3C HTML Validator It is good practice to write HTML that passes the W3C HTML Validator with flying colors. It also shows potential clients/employers that you can code properly. Unfortunately, for any HTML page subject to tracking by a PHP Session, you can end up looking less than perfect in this regard (unless url encoding of the session ID is disabled in the php.ini file, but the downside of doing this is that anyone who has cookies turned off will not be able to interact with such a site). This is because the W3C Validator does not accept cookies, so PHP automatically appends the PHPSESSID to every local HTML hotlink on the page; the usual solution PHP uses to get around browsers that have cookies disabled. The problem is that the Validator treats the PHPSESSID as an "unidentified entity" - and red-flags each occurrence as an error. Without being really sneaky, such as turning off the session for any page served to the W3C site (would I do such a thing?) the only answer I have found is to do page handoffs using JavaScript instead: First, the JavaScript: function newpage(pageURL) { location.replace(pageURL); } Next, an example of the HTML work-around: <a href="javascript:void(0)" onclick='newpage("./index.php" title="Home Page")'> This works because PHP only looks for the URL to append the PHPSESSID to in the 'href' attribute of the <a> tag, and the above bit of code has moved it from there into the 'onclick' attribute. If anyone has a better work-around, I'd love to know what it is. ---- Manual Page -- http://www.php.net/manual/en/faq.html.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57868 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57868&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57868&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57868&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57868&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57868&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57868&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57868&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57868&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97116) next »