Page 1 of 1

session problems

Posted: Mon Apr 28, 2003 7:10 am
by irealms
Firstly i'm new to php and so this will no doubt be an easy answer to most of you :lol:

I am trying to implement a login script, the script works fine at the moment but when i tried to use the script included into my index page i kept getting session cache errors. I then added the site code into the script itself and the form works. the problem i have now is i want to have the "you are logged in as " link on all pages and when i tried adding :

<?
session_start();
echo "members";
if (session_is_registered("valid_user")) {
echo "you are logged in as $valid_user";
}
else {
echo "you are not logged in";
}
?>

to my index page i got this error:

Warning: Cannot send session cache limiter - headers already sent (output started at /home/httpd/vhosts/irealms.co.uk/httpdocs/crimson/index.php:27) in /home/httpd/vhosts/irealms.co.uk/httpdocs/crimson/index.php on line 46
membersyou are logged in as test

any idea why i am getting this error?

the site in question is http://www.irealms.co.uk/crimson

as you can see the link are in the form index.php?page=page name

I had to make a standard link for the login page as i was getting the above error when trying to include it in my index page.

Any help is greatly appreciated :?

Posted: Mon Apr 28, 2003 7:24 am
by volka
Please read Sticky: Before Post Read: Sessions with a Minor in User Logins which is (somehow) related to Sticky: Before Post Read: Warning: Cannot add header information.
Theese are not sticky threads for nothing ;)

If you wonder why session_is_registered is not mentioned there also read http://www.php.net/manual/en/ref.sessio ... n.examples and Sticky: Before Post Read: Concerning Passing Variables in PHP 4.2+

...welcome ;)

thanks

Posted: Mon Apr 28, 2003 7:38 am
by irealms
yeah sorry just me being blind 8O

read those posts and managed to get rid of the error by adding

ob_start();
session_start();

to my config file

think it's sorted now, though i'm sure i'll have many more questions soon, hehe