Jump to content

Cookie Help (Actually got code this time)


RaythMistwalker

Recommended Posts

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
Share on other sites

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
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.