Can't seem to destroy cookies
Posted: Sun Dec 13, 2009 12:08 pm
Hey all, I'm hoping someone may be able to clarify some confusion I have about cookies. I feel kinda silly about having to ask - I've been working with php as an amateur for about a year now and thought I had mostly everything down pat.
I'm hosting an intranet site that redirects the user to their directory on the server. I have this portion set up and functioning, but for some reason I can't seem to get any sort of logout script to work. I do know sessions are more secure and probably more appropriate for the purpose, but I'm trying to force myself to learn about cookies.
Upon validating a logon, I've placed this:
Now, everything I've seen regarding destroying cookies says to set the expire time to before 'now.' and despite trying several different described methods, nothing seems to work. I've even tried setting an expire time in the cookie, but to no avail.
Is it possible I'm missing something, or might I need to change some settings in php.ini? Any advice here would just be fantastic.
Oh, a little about the server, in case it helps
I'm running Ubuntu Desktop 9.10 with Apache2, PHP5, and MySQL - all are the most recent version (as of December 2009)
I'm hosting an intranet site that redirects the user to their directory on the server. I have this portion set up and functioning, but for some reason I can't seem to get any sort of logout script to work. I do know sessions are more secure and probably more appropriate for the purpose, but I'm trying to force myself to learn about cookies.
Upon validating a logon, I've placed this:
Code: Select all
$username = $_REQUEST['username'];
setcookie('user' , $username); Is it possible I'm missing something, or might I need to change some settings in php.ini? Any advice here would just be fantastic.
Oh, a little about the server, in case it helps
I'm running Ubuntu Desktop 9.10 with Apache2, PHP5, and MySQL - all are the most recent version (as of December 2009)