Session variables in php

When I declare and call session variables, this error message always comes up:
Warning: Cannot send session cookie - headers already sent by (output started at /home/.decker/threerr/ in /home/.decker/threerr/ on line 17

My code is:

<? session_start(); session_register("sess_var"); $sess_var="Hello"; echo " the value of sess_var is $sess_var
."; ?>

Does anyone know of special syntax or file permisions needed to set session vars in DH? Or a way to work around the automatic php session that causes this error?


One thing to check is that every file used in this page call (i.e. every file that is included by any file) has no white space before or after the <? and ?> markers. That means no empty line and no spaces before or after those markers.

Those are enough to send output to the browser and thus make it impossible to send headers.

–David B.

I was embedding the php code after html header and body tags. Once I put the <? on the first line, then the html, all was fine.

Many thanks for the clue!


Happy to be of service!

–David B.