Re: session control query
| From: | Veniamin Goldin | Date: | Fri, 03 Oct 2003 10:40:42 +0000 |
| Subject: | Re: session control query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164874@lists.php.net to get a copy of this message | ||
Hi,
session_start(); must be a very first line of script. Before any
html output.
Regards,
Veniamin
SS> Hi there,
SS> I'm currently working on a user login script. I'm using session
SS> variables. Everything seems to be working fine but I continually get the
SS> following warning message when I run the programs:
SS> Warning: Cannot send session cache limiter - headers already sent
SS> (output started at c:\phpdev\www\staffdb2\side_menu.php:3) in
SS> c:\phpdev\www\staffdb2\side_menu.php on line 4
SS> The side_menu.php routine is below:
SS> <LINK REL=STYLESHEET HREF="styles.css" TYPE="text/css">
SS> <BODY class="sidebar">
SS> <?PHP
SS> session_start();
SS> //require_once('user_auth_fns.php');
SS> //check_valid_user();
SS> if (isset($HTTP_SESSION_VARS['valid_user']))
SS> {
SS> echo '<a href="logout.php">Log out</a>';
SS> }
SS> else
SS> {
SS> echo 'You are not logged in';
SS> }
?>>
SS> The session variable 'valid_user' is set in the following routine:
SS> <?PHP
SS> require_once('staffdb_fns.php');
SS> session_start();
SS> $username=$HTTP_POST_VARS['username'];
SS> $passwrd=$HTTP_POST_VARS['passwrd'];
SS> if ($username && $passwrd)
SS> {
SS> if (login($username,$passwrd))
SS> {
SS> $HTTP_SESSION_VARS['valid_user']=$username;
SS> display_page_layout();
SS> }
SS> else
SS> {
SS> echo 'login failed';
SS> display_login_form();
SS> exit;
SS> }
SS> }
SS> else
SS> {
SS> display_login_form();
SS> }
SS> //check_valid_user();
?>>
SS> Any ideas.
SS> PS : I am rather new to php so be kind please.
SS> Regards,
SS> Steve.