prob with session start

From: Date: Mon, 13 Aug 2001 11:03:49 +0000
Subject: prob with session start
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.general 
Request: Send a blank email to php-general+get-62402@lists.php.net to get a copy of this message
Hi! friend, I want to start session if authentication is succesfull means if he is a valid user. Then what i have to do Renze?? Thanks in advance. With warm regards -Balaji ----- Original Message ----- From: Renze Munnik To: Balaji Ankem Cc: php-general@lists.php.net Sent: Monday, August 13, 2001 2:04 PM Subject: Re: [PHP] plz check the warning message On Mon, Aug 13, 2001 at 02:01:59PM +0530, Balaji Ankem wrote: > Hi! Renze, > Thanks a lot for u'r help. I am in vacation up to now. > Now i am trying with u'r solution. I am getting the following error. > I am sending the file also. > > Warning: Cannot send session cache limiter - headers already sent in > c:\www\authentication.php on line 34 > > > File:authentication.php > <?php > header ("Cache-Control: no-cache, must-revalidate"); > header ("Pragma: no-cache"); > > error_log ("emp_id: $emp_id", 0); > error_log ("Lastname: $emp_pass", 0); > > // Connect to MySQL > > mysql_connect( 'localhost', 'balaji', 'pingpong' ) > or die ( 'Unable to connect to server.' ); > > // Select database on MySQL server > > mysql_select_db( 'imac' ) > or die ( 'Unable to select database.' ); > > // Formulate the query > > $sql = "SELECT * FROM employee WHERE > emp_id = '$emp_id' AND emp_pass = '$emp_pass'"; > > // Execute the query and put results in $result > > $result = mysql_query( $sql ) > or die ( 'Unable to execute query.' ); > > // Get number of rows in $result. > > $num = mysql_numrows( $result ); > > if ( $num != 0 ) { > // A matching row was found - the user is authenticated. > session_start(); > session_register('$emp_id'); > > $row = mysql_fetch_object($result); > > if ($row->user_type=='S') > { > include('super.php'); > > } > else if ($row->user_type=='O') > { > include('ordinary.php'); > > } > } > > else > { > file://User does not exist or not authenticated. > echo '<center><h1>Authorization > Required.</h1></center>'; > file://header( 'WWW-Authenticate: Basic realm="Private"' ); > file://header( 'HTTP/1.0 401 Unauthorized' ); > exit; > } > > ?> Well... You can't sent any headers after some output has already been sent. I didn't take a very good look at your code, but looking at the warning you get and the position of session_start() in your code, I'd say you have to move the session_start() up. You can best start your code with session_start() and then the rest of your script. -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- H: +31 23 5516190 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- -- http://www.datalink.nl -- «««««««««««««««««««««««« -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

----------------------------------------------------------------------------------------------------------------------- Information transmitted by this E-MAIL is proprietary to Wipro Limited and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at mailto:mailadmin@wipro.com and delete this mail from your records. ------------------------------------------------------------------------------------------------------------------------
« previous php.general (#62402) next »