Re: Re: HTTP header information

From: Date: Thu, 10 Jun 2004 14:56:44 +0000
Subject: Re: Re: HTTP header information
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-34714@lists.php.net to get a copy of this message
On Jun 10, 2004, at 9:44 AM, Torsten Roehr wrote:
"Philip Thompson" <prthomp@uark.edu> wrote in message news:701321CF-BAE4-11D8-BFD5-000393C795C4@uark.edu...
Hi all. I am running a website to where a user needs to login to authenticate themselves to perform certain tasks. So a user logs in, and I start a session (in PHP, of course). Well, the catch is, I am doing this all from one page, 'viewer.php', and I just tack on the specific view/page that I want them to see, depending on the link selected on that page. Meaning, they click on the 'submit problem' link and it goes to 'viewer.php?type=submitproblem'. The problem comes whenever I load the view 'submitproblem' and I start a session with session_start(), which carries over the variable to tell whether or not the user is logged in. If they have not logged in whenever they click on 'submitproblem' then it will redirect them to 'viewer.php?type=login'. So I log in, and then go to 'submitproblem'. This is where I get the error: "Warning: session_start(): Cannot send session cookie - headers already sent". Essentially, I understand why this is occurring, but is there an easy way to get around it without creating a new page, such as 'submitproblem.php' instead of 'viewer.php?type=submitproblem'???
Make sure that NO output is done before session_start() is called. Can you post some of your code? Regards, Torsten Roehr
See, that's the case. Because I'm essentially just changing the content within the page, it never leaves the page 'viewer.php' - it just changes the content by tacking on '?type=login, submitproblem, etc'. But my code in the beginning of the file 'submitproblem.view' is: <?php session_start(); if (!session_is_registered('_isLoggedIn')) { header ("Location:viewer.php?type=login"); } else { // do the stuff to submit a problem if they have // logged in and have pressed the "submit" button // in the html } ?> // then here is all the html for that page So, does that help any? ~Philip

« previous php.db (#34714) next »