Hi Guys

I'm working on a little log in syetms for my website, hwoever have hit a little snag. I'm using cookies to track which users are logged in. I'm trying to make some pages restricted to vistors that have logged in only, so I decided to use if($_COOKIE["loggedIn"] == TRUE){ This works for the log in page but when I logout using Inline setcookie("loggedIn", NULL, time() - 60000); All the other pages apart from the log in page retain the value TRUE. I originally set the cookie setcookie("loggedIn", TRUE, time() + 3600);. I'm still very new to php so any help would be greatly appreciated

http://php.net/setcookie

"Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client. This is internally achieved by setting value to 'deleted' and expiration time to one year in past."

Ah ok thanks for the link.

Okay so i though I fixed it, It started working for a bit then stopped. Even when I log in with a different user teh username cookie doesn't change. I've only started using php for a week or two am very unfamiliar with it.

I've tried subsituting cookies with sessions. It starts to work and then the same problem occurs. My log in page is pat of an include file, would this make a difference?

No. Should work. Perhaps overlooked something somewhere.

if the file with the session in is an include file should the start_session() be in there or from the parent file?

It should called as soon as possible in your code.

http://php.net/manual/en/function.session-start.php
session_start() should be called before doing anything with sessions. It should ideally be called before any output to the browser. You will get headers already sent errors if you try to use it after any kind of output.