Jump to content

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.

 

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.