|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16342 can not set cookie with domain specified
Submitted: 2002-03-29 07:36 UTC Modified: 2002-06-12 14:51 UTC
From: myaddress at iname dot com Assigned:
Status: Closed Package: HTTP related
PHP Version: 4.1.1 OS: cookies and domain
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: myaddress at iname dot com
New email:
PHP Version: OS:


 [2002-03-29 07:36 UTC] myaddress at iname dot com
If I specify a domain, cookie is not set:

This works:
$exp = time()+120;
setcookie ("TestCookie", "TEST$exp",$exp);

This doesn't work:
$exp = time()+120;
setcookie ("TestCookie", "TEST$exp",$exp, "/", "");

Doesn't set a cookie at all. Any ideas?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-13 18:52 UTC]
Try this:

setcookie("test_cookie", "test$exp", $exp, "/", "");

Also, don't forget that you can just write your own header with the header() function. If, for some reason, there *is* a problem with setcookie(), you can always just write your own to be sure.

If my above example doesn't fix the problem, please try to give me the HTTP traffic, specifically the response. If you're unsure how to do this, feel free to email me personally.

Hope that helps.

 [2002-06-12 14:51 UTC]
It's been 60 days without a response. Please reopen this bug if it still persists. Otherwise, I will assume my last comment resolved it for you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 14:03:36 2021 UTC