Error initializing session and registering session variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hounkanrinjp
Forum Newbie
Posts: 6
Joined: Mon Aug 19, 2002 8:39 am

Error initializing session and registering session variables

Post by hounkanrinjp »

Hi, The problem is very simple. First let me show you the code:

Code: Select all

$verified_user = $varname;
	session_start();
	session_register("$verified_user");
	print "Welcome dear <u>$verified_user</u>. You will be automatically redirected to the main page in a few seconds.";
	print "<meta http-equiv="refresh" content="0;URL=_overview.php">";
now, when the user logs in, it works fine, but the session can't start and the variable can't be registered. Here is exactly the kind of error I get:


Warning: Cannot send session cache limiter - headers already sent (output started at c:\cms\_verify.php:14) in c:\cms\_verify.php on line 35


Does anyone here knows what's wrong and why i get such and error?
Is is a problem of server configuration or PHP configuration or anything like that? I would really appreciate it if i could get an answer as quicly as possible. Thank you gentlemen! :wink:
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

What does line 14 of c:\cms\_verify.php look like or is that what you have posted. Show us everything through line 14?

Direwolf
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

Yeah, you can't do session_start() after you've output HTML already, because PHP needs to send a cookie with the session_id in it. Probably, you've got some HTML being output on line 14.
hounkanrinjp
Forum Newbie
Posts: 6
Joined: Mon Aug 19, 2002 8:39 am

Post by hounkanrinjp »

Hi, in fact, I've been wandering on PHPBuilder and I found a topic with the same question and the told the guy not to output any HTML before beginning the session. Tanx guys.
Post Reply