470,636 Members | 1,970 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

cannot expire cookie

Hi,
I am having problems expiring cookies in PHP, i.e. when you want to
logout of an application.

Has anyone had this problem, and what is the solution. Working code is
appreciated.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-expire-c...ict168002.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=562929
Jul 17 '05 #1
4 1956
steve <Us************@dbforumz.com> wrote:
I am having problems expiring cookies in PHP, i.e. when you want to
logout of an application.

Has anyone had this problem, and what is the solution. Working code is
appreciated.


Show us your code, maybe we can pinpoint the problem.

FUP: comp.lang.php

--

Daniel Tryba

Jul 17 '05 #2
"user782" wrote:
steve <Us************@dbforumz.com> wrote:
I am having problems expiring cookies in PHP, i.e. when you

want to
logout of an application.

Has anyone had this problem, and what is the solution.

Working code is
appreciated.


Show us your code, maybe we can pinpoint the problem.

FUP: comp.lang.php

--

Daniel Tryba


sorry I should have provided code:

setcookie("user", "", mktime(12,0,0,1, 1, 1990), "/");

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-expire-c...ict168002.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=562956
Jul 17 '05 #3
Just set a new cookie with the same name when they "log out" and set an
expired time on the cookie. Either that or set no time on it and have
it expire when they close the window or leave the page.

Jul 17 '05 #4
> setcookie("user", "", mktime(12,0,0,1, 1, 1990), "/");

The code above should clear the "user" cookie, but only
if it was set with path parameter "/" and with time
set (AFAIK session cookies - set with zero time - cannot
be forced to expire, but can be cleared; you have to
provide zero as time in clearing command).

Remember that setting cookies (or clearing them) does not
mean that you'll see the changes in the script in which
you changed the cookie (you need reload or something).

Hilarion
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Carlos Marangon | last post: by
6 posts views Thread by David Graham | last post: by
7 posts views Thread by What-a-Tool | last post: by
3 posts views Thread by Joey Powell | last post: by
2 posts views Thread by Gonzosez | last post: by
23 posts views Thread by Phil Powell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.