mackncheeseyx Posted February 25, 2011 Share Posted February 25, 2011 Hey there (: I'm doing a resume site for the FBLA club at my highschool. I'm also learning PHP along the way. I'm sure this is pretty obvious, but i'm getting this error, and I cant figure out what it means: Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home2/bythewa1/public_html/resume/profile.php:5) in /home2/bythewa1/public_html/resume/profile.php on line 7 Here is my page code: <? include($root_path.'includes/header.php'); ?> <? if(!isset($_SESSION['login'])) { session_register('login, userid, firstname, lastname'); } if($_GET['logout'] == 'yes') { session_unregister('login'); session_unregister('userid'); session_unregister('firstname'); session_unregister('lastname'); } //die("In"); if(!$_SESSION['login'] == 0) { // die("Here"); ?> <script language="javascript"> window.location = 'http://resume.derekbtw.com/index.php'; </script> <? } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <h1><a href="<?=$_SERVER['PHP_SELF']?>?logout=yes">logout</a></h1> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/ Share on other sites More sharing options...
denno020 Posted February 25, 2011 Share Posted February 25, 2011 session stuff has to be at the very top of your php file. It has to be the very first thing that is read by the server. Move session_register to just after the '<?php' tag, well '<?' in your case. Also to not, session_register is deprecated, meaning it is being phased out of use, you simply use $_SESSION['field_name_here']; now. Source: http://php.net/manual/en/function.session-register.php. Hope that helps Denno Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179326 Share on other sites More sharing options...
mackncheeseyx Posted February 25, 2011 Author Share Posted February 25, 2011 session stuff has to be at the very top of your php file. It has to be the very first thing that is read by the server. Move session_register to just after the '<?php' tag, well '<?' in your case. Also to not, session_register is deprecated, meaning it is being phased out of use, you simply use $_SESSION['field_name_here']; now. Source: http://php.net/manual/en/function.session-register.php. Hope that helps Denno But I need my header insert at the top of the page..or my login wont work.. Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179335 Share on other sites More sharing options...
Pikachu2000 Posted February 25, 2011 Share Posted February 25, 2011 http://www.phpfreaks.com/forums/php-coding-help/header-errors-read-here-before-posting-them/ Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179336 Share on other sites More sharing options...
litebearer Posted February 25, 2011 Share Posted February 25, 2011 Agree with session at top and reading about HEADER; however... ??? perhaps he has chosen an unfortunate name for his file. The key would be the content of header.php ??? Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179338 Share on other sites More sharing options...
denno020 Posted February 25, 2011 Share Posted February 25, 2011 Yes, post your code for header.php so we can see why you need that first.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179345 Share on other sites More sharing options...
mackncheeseyx Posted February 25, 2011 Author Share Posted February 25, 2011 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>- Student Resume</title> <link rel="stylesheet" href="http://www.resume.derekbtw.com/stylesheets/default.css" type="text/css" /> </head> <div id="wrap"> <div id="header"> <center><span class="logo"> <a href="http://www.resume.derekbtw.com"><img src="http://resume.derekbtw.com/images/logo.png" height=""/></a> <br></span></center> <ul id="navigation"> <li<?=($home ? ' class="active"' : '')?>><a href="../index.php" style="text-decoration:none">Home</a></li> <? if($_SESSION['login'] == 0) { ?> <li<?=($register ? ' class="active"' : '')?>><a href="../register.php" style="text-decoration:none">Register</a></li> <? } ?> <? if($_SESSION['login'] == 0) { ?> <li<?=($login ? ' class="active"' : '')?>><a href="../login2.php" style="text-decoration:none">Login</a></li> <? } ?> <li<?=($about ? ' class="active"' : '')?>><a href="../about.php" style="text-decoration:none">About</a></li> <li<?=($contact ? ' class="active"' : '')?>><a href="../contact.php" style="text-decoration:none">Contact</a></li> <? if($_SESSION['login'] == 1) { ?> <li<?=($profile ? ' class="active"' : '')?>><a href="../profile.php" style="text-decoration:none">Profile</a></li> <? } ?> </ul> </div> <div id="content"> <? if($_SESSION['login'] == 1) { ?> Welcome, <? print strtoupper($_SESSION['firstname'][0]). substr($_SESSION['firstname'],1, strlen($_SESSION['firstname'])); ?> <? } ?> Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179403 Share on other sites More sharing options...
denno020 Posted February 25, 2011 Share Posted February 25, 2011 Alright, add session_start() as the very fist thing after the <? tag. See if that helps.. Denno Quote Link to comment https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179404 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.