PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, here's the situation..I've written a simple(at the moment) script that will create user accounts, and allow users to log in. As part of the layout I want to add a script that will give a logged in user links, or if not logged in a login box. The way the layout is set up, is I have two files which contain the layout that are included using php's include function on every page. The following is the code I have to check to see if the user is logged in and print out the info I want:
This is where it gets weird. If you access the file directly(i.e. viewing the actual file the code is in in your browser), it works without a hitch. However, if you access the file on a page it is being included on, it will echo out the form to login, even though it should be echoing out the Welcome message as it does if the file is accessed directly. I can't think of any reason for this to be happening and would appreciate any help.
Apparantly not...when I throw an else statement in there and go to a page on which it is included it returns what I ask it to if it is not set. Though, because the value is stored in a cookie this seemingly shouldn't be.
I've found the problem...in my include statement I was using a URL to include the files. I changed it to use the path instead and the script works perfectly.