Jump to content

Recommended Posts

Hi Everyone

 

In the following code I'm getting an error with the isset in my error log.

		if(isset($_COOKIE['user']))
			{
				echo "<p>Logged in as".$_COOKIE['user']."</p>";
			}

		else 
			{
				echo "You are currently using AGG as a <a href='index.php?page=guests explained' alt='Explains what a guest is and how you are limited in the sites functionality'>Guest.</a>"
			}

 

Just wondering what I'm doing wrong.

 

Any ideas or help are appreciated.

 

Timothy

Link to comment
https://forums.phpfreaks.com/topic/265376-isset-problems/
Share on other sites

Depends what the error is, because (a) isset() practically never throws any kinds of errors ever and (b) that code you posted is fine. Besides the alt/title thing. And missing a space between the "an" and the username. And that one branch of the if outputs a block-level element while the other branch outputs text. And HTML injection because cookies come from the user and cannot be trusted. And I'm a bit concerned that you may be using cookies as your only authentication mechanism without validating the username and/or credentials first.

 

Mostly fine.

Link to comment
https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360030
Share on other sites

Thanks everyone for your help. I found my error. (Scroll Across Below)

$cookieuser = $_COOKIE['user'];
		if(isset($cookieuser))
			{
				echo "<p>Logged in as ".$_COOKIE['user']."</p>";
			}

		else 
			{
				echo "You are currently using AGG as a <a href='index.php?page=guests explained' title='Explains what a guest is and how you are limited in the sites functionality'>Guest.</a>" //// I forgot to put the semi-colon here to finish the statement. 
			}

 

Thanks heaps for your time and effort.

Timothy

Link to comment
https://forums.phpfreaks.com/topic/265376-isset-problems/#findComment-1360031
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.