Sorry to drag up an old topic, but I'd rather do this than start my own.
I've had this problem with an old site of mine, where the SESSION data seemed to suddenly get cleared from page to page. I was never able to resolve the problem.
Now, once again I am resorting to using SESSIONS heavily for a log-in type part of my site. This time I can't even get my sessions to work once.
I go to my first page that has SESSIONS, and my page goes nuts and says:
Quote:
XML Parsing Error: junk after document element
Location:
http://joelson.farvista.net/joelson/Line Number 3, Column 1: <b>Warning</b>: session_start(): Cannot send session cookie - headers already sent by (output started at /home/www/joelson.......
Now, I have my website and sessions working PERFECTLY on my local machine and server. There are no problems at all. However, when the pages are on 100webspace, the sessions are all of a sudden being sent AFTER other page output has begun...
Hmmm... I wonder what this could be
I'm putting my preliminary blame on the free ads. No, I have nothing wrong with ads on my free pages, and I like how unobtrusive they are. However, the code for the ads is wildy invalid for the XHTML standards I code with.
However 100webspace inserts these ads into your site, they are apparently adding them extremely close to, if not at, the top of your page. This may be showing up before any of your PHP code and session variables. This beginning of output on the page prevents PHP from changing any session data/cookies. That (in my educated guess) is why session data is lost over pages - the ads prevent the sessions from working correctly.
Now, you might wonder why your data is lost but you don't get the nasty error message I have. The simple answer to that is I send my webpages with the MIME type "application/xhtml+xml," which forces compatible browsers to parse pages correctly. If you are using Internet Explorer 6.0 or below, the pages (and ads) will display fine, except the sessions won't work. However, if you are using a web standards browser such as Opera, Firefox (my favorite
), or [finally compliant] IE 7 (beta), then "application/xhtml+xml" activates the XML parsing in the browser, and it will pop up with the error I receive.
In short, if your sessions are not working, it is most likely because of the free ads placed on your page by 100webspace. Until 100webspace cleans up the code and how they insert it into pages, this is simply another thing that will linger by and irk people who write clean, valid code. (I wrote some other stuff on the ads in
this locked topic.)
But, since I didn't intend this as SIMPLY a rant against the invalidly-written ads post (:lol:), has anyone out there gotten their session variables to work correctly (on the free hosting)? If so, how?