RaythMistwalker Posted October 28, 2011 Share Posted October 28, 2011 Ok I have the following as part of a login script which is supposed to set a cookie upon successful login if (mysql_num_rows($LoginResult) > 0) { $UserID = mysql_result($LoginResult, 0, 'user_id'); $Id = uniqid(); $IdRes = mysql_query("UPDATE ".MEMBER_LOGIN_TABLE." SET `unique_id`={$Id} WHERE user_id='{$UserID}", $db); setcookie('RAYTH_MEMBER_ID', $Id, time()+2592000); Echo "Logged In. Click <a href='index.php?act=idx'>Here</a> to Continue.<br>Note: If you click continue and you are not logged in please ensure cookies are enabled!"; } [/cookie] However when I log in I get: [code] Warning: Cannot modify header information - headers already sent by (output started at /home/rayth/public_html/style.php:1) in /home/rayth/public_html/login.php on line 38 Logged In. Click Here to Continue. Note: If you click continue and you are not logged in please ensure cookies are enabled! Line 38 is the setcookie() line. Can someone shed light on where I am going wrong here? Link to comment https://forums.phpfreaks.com/topic/249946-cookie-help-actually-got-code-this-time/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 28, 2011 Share Posted October 28, 2011 output started at /home/rayth/public_html/style.php:1 Something on line 1 of style.php is sending output to the browser, which prevents the header/cookie from working. I'll guess you either have a blank line, some css, or a BOM (Byte Order Mark) character. See this sticky post for information on this popular error - http://www.phpfreaks.com/forums/index.php?topic=37442.0 Link to comment https://forums.phpfreaks.com/topic/249946-cookie-help-actually-got-code-this-time/#findComment-1282888 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.