ohdang888 Posted February 21, 2009 Share Posted February 21, 2009 I'm getting an error when i set cookies: Warning: Cannot modify header information - headers already sent by (output started at /home/socialap/public_html/bookmark/include/head.php:2) in /home/socialap/public_html/bookmark/include/brain.php on line 75 Warning: Cannot modify header information - headers already sent by (output started at /home/socialap/public_html/bookmark/include/head.php:2) in /home/socialap/public_html/bookmark/include/brain.php on line 76 Warning: Cannot modify header information - headers already sent by (output started at /home/socialap/public_html/bookmark/include/head.php:2) in /home/socialap/public_html/bookmark/include/brain.php on line 77 Code: setcookie('u', $recon_key, $expire); setcookie('k', $recon_k, $expire); setcookie('e', $this->salt_password($email), $expire); Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/ Share on other sites More sharing options...
Cal Posted February 21, 2009 Share Posted February 21, 2009 Make sure that setcookie is used at the top of the page, Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767826 Share on other sites More sharing options...
ohdang888 Posted February 21, 2009 Author Share Posted February 21, 2009 i can't set cookies in the middle? so i should do this: <?php session_start(); setcookie(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767827 Share on other sites More sharing options...
Cal Posted February 21, 2009 Share Posted February 21, 2009 Yes Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767829 Share on other sites More sharing options...
ohdang888 Posted February 21, 2009 Author Share Posted February 21, 2009 doesn;'t work] Warning: setcookie() expects at least 1 parameter, 0 given in /home/socialap/public_html/bookmark/include/brain.php on line 3 Bookmark Warning: Cannot modify header information - headers already sent by (output started at /home/socialap/public_html/bookmark/include/brain.php:3) in /home/socialap/public_html/bookmark/include/brain.php on line 76 Warning: Cannot modify header information - headers already sent by (output started at /home/socialap/public_html/bookmark/include/brain.php:3) in /home/socialap/public_html/bookmark/include/brain.php on line 77 Warning: Cannot modify header information - headers already sent by (output started at /home/socialap/public_html/bookmark/include/brain.php:3) in /home/socialap/public_html/bookmark/include/brain.php on line 78 Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767830 Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2009 Share Posted February 21, 2009 doesn;'t work Read the error, it tells you what is wrong - setcookie() expects at least 1 parameter, 0 given You did not supply any parameters in the setcookie() function call. Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767834 Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 And you have output before that opening php tag. White space, or other text or something. Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767835 Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2009 Share Posted February 21, 2009 And the other errors (output started at line 3) are due to the Warning: setcookie() expects ... message being output on line 3. Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767838 Share on other sites More sharing options...
ohdang888 Posted February 21, 2009 Author Share Posted February 21, 2009 well i need sesion_start there too. Is it okay to have both? Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767839 Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 Ignore what I said. Pmfwsbbakdsdt was right. Put values into your setcookie function, and you will solve your problem. Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767852 Share on other sites More sharing options...
ohdang888 Posted February 21, 2009 Author Share Posted February 21, 2009 should i set all cookies through this function? "setcookie();"?? or just once i call that once, and then do $_COOKIE['var'] = $var ?? thanks Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767939 Share on other sites More sharing options...
jackpf Posted February 21, 2009 Share Posted February 21, 2009 Also, you don't need session_start() when setting cookies alone. You only need that for sessions Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-767983 Share on other sites More sharing options...
ohdang888 Posted February 21, 2009 Author Share Posted February 21, 2009 like i said, i need session start there. i'm still getttin this error Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-768049 Share on other sites More sharing options...
Philip Posted February 21, 2009 Share Posted February 21, 2009 doesn;'t work Read the error, it tells you what is wrong - setcookie() expects at least 1 parameter, 0 given You did not supply any parameters in the setcookie() function call. Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-768052 Share on other sites More sharing options...
ohdang888 Posted February 21, 2009 Author Share Posted February 21, 2009 sorry, forgot to tell you i did that step... <?php session_start(); setcookie('0','0', 1); i'm not getting an error from the 3rd line, but i am still getting them from the other lines Quote Link to comment https://forums.phpfreaks.com/topic/146259-error-setting-cookies/#findComment-768053 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.