Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,904 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,742 people online right now. Registration is fast and FREE... Join Now!




PHP Cookies not working right!

 
Reply to this topicStart new topic

PHP Cookies not working right!, Issues deleting PHP Cookies

spearfish
10 Mar, 2008 - 06:25 AM
Post #1

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
Alright, here's what's going on:

I'm trying to create a login / logout system for a game me and my friends are working on, this is my first PHP project. I'm teaching myself, so I don't have a teacher to ask this to.

Anyways, for the logout system, you click a link to the logout page, logmeout.php, and it will delete the cookie for you. Then you are redirected to the home page. I've seen this successfully implimented before, such as on conquerclub.com.

Here's what I'm at right now:

CODE
<?php
setcookie("account", "", 1);
header( 'Location: http://www.sbboard.com/auslander/home.php ');
?>


I've also tried it with
CODE
setcookie("account", "", time()-36000);
;
CODE
setcookie("account", "", 1, '/');
; and
CODE
setcookie("account", "", time-36000, '/');
.

The weird part is that after the user has manually deleted the first cookie, their computer can seemlessly log in and out, functioning how it's supposed to. I've also confirmed this by checking my cookies --- it's not a cache issue, the cookie simply isn't deleted the first time around crazy.gif

Any insight would be great
User is offlineProfile CardPM
+Quote Post

JBrace1990
RE: PHP Cookies Not Working Right!
10 Mar, 2008 - 12:32 PM
Post #2

D.I.C Regular
Group Icon

Joined: 9 Mar, 2008
Posts: 477



Thanked: 22 times
Dream Kudos: 350
My Contributions
CODE
setcookie("account", "", time() - 3600);


that is how it should be done... if it's not working, make sure you chose the correct name of the cookie... also, I would suggest sing Sessions instead of cookies because they're much more secure...
User is offlineProfile CardPM
+Quote Post

spearfish
RE: PHP Cookies Not Working Right!
10 Mar, 2008 - 03:46 PM
Post #3

Monkey in Training
Group Icon

Joined: 10 Mar, 2008
Posts: 746



Thanked: 2 times
Dream Kudos: 225
My Contributions
QUOTE(JBrace1990 @ 10 Mar, 2008 - 01:32 PM) *

CODE
setcookie("account", "", time() - 3600);


that is how it should be done... if it's not working, make sure you chose the correct name of the cookie... also, I would suggest sing Sessions instead of cookies because they're much more secure...



I've tried it like that, only to receive the same results.

How would I do it with sessions?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 09:46PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month