killfall Posted January 31, 2010 Share Posted January 31, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/190467-_cookie-include-problem/ Share on other sites More sharing options...
wildteen88 Posted January 31, 2010 Share Posted January 31, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/190467-_cookie-include-problem/#findComment-1004677 Share on other sites More sharing options...
killfall Posted January 31, 2010 Author Share Posted January 31, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/190467-_cookie-include-problem/#findComment-1004738 Share on other sites More sharing options...
wildteen88 Posted January 31, 2010 Share Posted January 31, 2010 Where are the variables $logoutform and $loginform defined? Quote Link to comment https://forums.phpfreaks.com/topic/190467-_cookie-include-problem/#findComment-1004741 Share on other sites More sharing options...
killfall Posted January 31, 2010 Author Share Posted January 31, 2010 In the same piece of code just above it. Quote Link to comment https://forums.phpfreaks.com/topic/190467-_cookie-include-problem/#findComment-1004755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.