xf_user cookie issue

liv4spd

Member
I am trying to use xf_user cookie to display different information depending on whether a user is logged on or not. Below is the code, I am thinking to use.

The problem is that when users are not logged in, xf_user is not definied, so I am getting a ton of the below error messages in my error log.
"undefinied index: xf_user".

Any idea, how I can get over this?

Thank you!


Code:
$bbuserid = $_COOKIE["xf_user"];

if ($bbuserid != '') {
// display information for users who are logged on:
......
}

if ($bbuserid == '') {
// display information for users who are not logged on:
......
}
 
Code:
$bbuserid = (isset($_COOKIE["xf_user"]) ? $_COOKIE["xf_user"] : '');

if ($bbuserid != '') {
// display information for users who are logged on:
......
}

if ($bbuserid == '') {
// display information for users who are not logged on:
......
}

That will fix the error message.
 
It works! Now my website is clear of errors(y)

I appreciate the big help very much.

Code:
$bbuserid = (isset($_COOKIE["xf_user"]) ? $_COOKIE["xf_user"] : '');

if ($bbuserid != '') {
// display information for users who are logged on:
......
}

if ($bbuserid == '') {
// display information for users who are not logged on:
......
}

That will fix the error message.
 
Top Bottom