RE: [PHP] Help Needed: Sessions

From: Date: Wed, 16 Aug 2000 14:54:23 +0000
Subject: RE: [PHP] Help Needed: Sessions
Groups: php.general 
Request: Send a blank email to php-general+get-12024@lists.php.net to get a copy of this message
> does it function now or are there other problems ? > Feel free to contact. > (If you haven't guessed by now, I'm a newbie to sessions, though I've been > working with Php for almost a year now.) > I'm running the page with the following to check for a session: > > if (!session_id()){ > session_start(); > session_register("UserData");} > > This seems to work, but I am having 2 problems: > (1) The header is being sent before the above lines of code are executed, > but there is nothing but an include statement and variable naming the page > before the statement. Even if I remove these statements and make it just > starting the session and registering the variable, it gives me the same > error as follows: > > Warning: Cannot send session cookie - headers alread sent by (output > started at index.php4:2) in index.php4 on line 4 > > Warning: Cannot send session cookie - headers alread sent by (output > started at index.php4:2) in index.php4 on line 4 > $UserData[SessionID]= > > The last line is my own line for testing whether the data is getting > through. Howevever, no matter what I do I cannot get rid of the other two > errors. I even got it on a page running the following code: > > <HTML><SCRIPT LANGUAGE="PHP"> > session_start(); > session_register("Counter"); > $Counter; > if (!isset($Counter)) $Counter = 0; > $Counter++; > $X = session_name(); > $Y = session_id(); > echo " I have seen this site $Counter times before."; > echo "<A HREF=Counter.php4?$X=$Y>Click Me</A>"; > </SCRIPT></HTLM> > > The php engine is not set to start sessions automatically. I'm at a loss > as to what to do. > (2)The variable information is not being carried over, so I can't access it. I have confirmed that the information IS being stored now in the server side session cookie, but I can't get to it at all. If I can solve problem #1, this may also be solved, but I am at a loss as to what to do. > Thanks for the help, > > Benjamen Meyer >

« previous php.general (#12024) next »