Jump to content

$_COOKIE include problem


killfall

Recommended Posts

I'm have a problem where I have written a login form which checks to see if the login cookie is set and depending on the answer it displays a login or logout form. When the script is run on its own it work fine but when I try and include it in another page it cannot find the cookie even if it is set. The script is in a folder below the page that is including it and I'm wondering if this is why it can't access the cookie.

Link to comment
https://forums.phpfreaks.com/topic/190467-_cookie-include-problem/
Share on other sites

As long as PHP is able to find the file you are trying to include then all variables should work fine. When developing your script it is recommend to set error_reporting to E_ALL and enable display_errors, for example place these two lines at the top of your script. These lines will temporarily enable errors

ini_set('display_errors', 1);
error_reporting(E_ALL);

 

Can you post the code you have issues with.

The code is just

if(isset($_COOKIE['cookiename'])){
/*Check username and token stored in cookie agains mysql database(this code works so I wont repeat it)*/
echo($logoutform); 
} else {
echo($loginform);
}
/*Where $loginform and $logoutform are set as strings containing code for html forms*/

 

And this code works until it is included in another page.

 

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.