| | |
Cookies not being deleted
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 46
Reputation:
Solved Threads: 0
Hi everyone,
Got a pesky little issue here with cookies. I have searched numerous forums and numerous posts of how to delete a cookie. So, I am much aware of this doing the trick:
Basically where not assigning any value to a cookie will delete it. (This is just to save some time
)
Anyways, I wish this was the case, but it's not working. I got it to work on a different portion of my application. However I had to come at it a different angle.
Basically, the way I wanted it to be was a user clicks the "logout" button and the cookies would be deleted and after being deleted, the user would be re-directed to the login page. But, instead I had to make a "logout.php" where the user is directed to this page, the delete cookie works fine, THEN gets directed to the login page.
I would use this technique for my current task in my application, but this would greatly complicate things.
Thanks in advance for any help.
Got a pesky little issue here with cookies. I have searched numerous forums and numerous posts of how to delete a cookie. So, I am much aware of this doing the trick:
php Syntax (Toggle Plain Text)
setcookie('cookie_name');
Basically where not assigning any value to a cookie will delete it. (This is just to save some time
)Anyways, I wish this was the case, but it's not working. I got it to work on a different portion of my application. However I had to come at it a different angle.
Basically, the way I wanted it to be was a user clicks the "logout" button and the cookies would be deleted and after being deleted, the user would be re-directed to the login page. But, instead I had to make a "logout.php" where the user is directed to this page, the delete cookie works fine, THEN gets directed to the login page.
I would use this technique for my current task in my application, but this would greatly complicate things.
Thanks in advance for any help.
Last edited by Zurompeta; Sep 19th, 2008 at 6:49 pm.
•
•
Join Date: Jul 2004
Posts: 234
Reputation:
Solved Threads: 8
php Syntax (Toggle Plain Text)
setcookie('cookie_name', time() - 42000);
•
•
Join Date: Jun 2007
Posts: 2
Reputation:
Solved Threads: 1
•
•
Join Date: Sep 2008
Posts: 46
Reputation:
Solved Threads: 0
*sigh*
See, I know this line of code should be working but it's just not, this is so frustrating. Does this line of code only work in IE or something?
See, I know this line of code should be working but it's just not, this is so frustrating. Does this line of code only work in IE or something?
Do you have a re-direct on the logout.php script? If you do comment this out and run the code to see if the cookies are being deleted at all, its possible depending on how your script works that it is re-creating the cookies when the user is re-directed.
The code is not browser defendant since PHP is a server side language not client side.
Personally I use the following code to delete cookies, but it does exactly the same as the previous examples:
The code is not browser defendant since PHP is a server side language not client side.
Personally I use the following code to delete cookies, but it does exactly the same as the previous examples:
php Syntax (Toggle Plain Text)
$past = time() - 3600; setcookie('cookie_name', null, $past);
Last edited by Will Gresham; Sep 21st, 2008 at 6:18 pm.
•
•
Join Date: Jan 2009
Posts: 3
Reputation:
Solved Threads: 0
Hello,
I realise this has now been resolved.. but is it possible that the problem was something to do with the path of your cookies?
For example: Your login page was creating a cookie and directing the user to the members page within a subdirectory, then the logout page was trying to delete a cookie which existed in the subdirectory instead of the root where it was created?
Pixel =)
I realise this has now been resolved.. but is it possible that the problem was something to do with the path of your cookies?
For example: Your login page was creating a cookie and directing the user to the members page within a subdirectory, then the logout page was trying to delete a cookie which existed in the subdirectory instead of the root where it was created?
Pixel =)
![]() |
Similar Threads
- session_start vs cookies (PHP)
- Can't remove Trojan horse (Viruses, Spyware and other Nasties)
- Deleted History (Geeks' Lounge)
- College Woes (Viruses, Spyware and other Nasties)
- Problem shutting down Windows XP Pro (Viruses, Spyware and other Nasties)
- what is this???? (Viruses, Spyware and other Nasties)
- Internet Explorer does not open when clicked (Web Browsers)
- hmmm..... (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: PHP/Ajax search facility
- Next Thread: include function not working URGENT!
Views: 1129 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update updates upload url validation validator variable video web xml youtube





