W3C strict validation and session_start() input hidden issue - not passing
Monday, June 30th, 2008
Couple of days ago, I’ve finished building a new website of mine for Design to XHTML service. One of the things needed for a such a project is having the page(s) passed W3C Strict Validation.
Everything was cool except for the phantom hidden input field that was holding PHPSESSID value. The problematic input field was positioned right after the <form> tag, and you can’t have that if you want to pass W3C strict. You have to enclose that field with a <p> or a <div>.
I’ve installed a JQuery SWFUpload for easy & user friendly upload experience, so I thought that script might be the one causing trouble. I’ve spent an hour running through lines and lines of code and couldn’t find nothing relating to my problem.
Since that was the only exotic part of code I was inserting, I turned over to session_start() as my primary suspect. I’ve stripped everything from the page, left only the form and the session_start() function call. Uploaded, W3C verified and that was it! For some reason session_start() invoked another hidden field in my form that didn’t render in my Firefox or Safari, but only in W3C. Knowing that, the only solution was simple:
if(!strstr(”$HTTP_USER_AGENT”, “Validator”)) {
session_start();
}
All I can say is I hope this saves somebody an hour of his life.
Technorati Tags: w3c, strict, validation, session_start, input, hidden, not passing













Couple of days ago I’ve came to a conclusion that I definitely need some sort of intranet, a way to track all of my projects and share project specs with my future employees.
