Friday, 10th June 2005
Dreamweaver MX and PHP Sessions
Here is an interesting (seemingly) bug i encountered in Dreamweaver MX 2004 and using it as a template for my website with PHP.
As you know, session tracking relies on either cookies (send as headers) or URL re-writing (session identifying info appended to URL) or hidden fields (programmer inserted info). Now based on server buffering and configuration, the headers need to be sent out before the HTML text.
In PHP5, to start session tracking, the session_start() function is used. Given that the server is not buffering HTML and the first HTML it recieves also implies the end of headers, the php code(script) to start the session needs to be before the tag. Easy enough right. Well here comes the catch. When you use the templating feature of Dreamweaver MX 2004 (and probably earlier versions as well), only updates between the and tag are considered when updating pages built using this template base.
So what that means is that changes to your php script at the top of the template page is not propogated to all pages build using this template. Darn, even though my script at the top of the page is just 1 line of text , it is not convenient for me to update each file with it.
One Option is to enable buffering in the server so that some HTML is buffered and the PHP script can be called within the tags.
But this violates my requirement of minimal dependency on the server configuration.
Well now for the workaround, i find out that Dreamweaver MX has a feature which allows updates outside the HTML tags to propogate to other pages. This is using the directive.
< !-- TemplateInfo codeOutsideHTMLIsLocked="true" -- >Posted by Nikhil on Friday, 10th June 2005 in TechnoBabble