0

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

Edited by bfitzgerald

3
Contributors
7
Replies
37
Views
4 Years
Discussion Span
Last Post by bops
1

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."

0

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.

Edited by bfitzgerald

0

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?

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.