#39994 [Bgs]: setcookie() docs don't say what to pass in "expire" to set a session cookie
| From: | jason191 at herkamire dot com | Date: | Mon, 08 Jan 2007 03:04:21 +0000 |
| Subject: | #39994 [Bgs]: setcookie() docs don't say what to pass in "expire" to set a session cookie | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969374729@lists.php.net to get a copy of this message | ||
ID: 39994
User updated by: jason191 at herkamire dot com
-Summary: setcookie() docs don't say what to pass in "expire" to
get a session cookie
Reported By: jason191 at herkamire dot com
Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
Assigned To: bjori
New Comment:
I'd put this in the description:
The Unix timestamp for when the cookie should expire or 0 for a session
cookie. (Session cookies should be kept until the browser closes.)
Default is 0. See also: time(), mktime()
And kill the second sentence in the example (since it's not an
example.)
Also, I think it is unreasonable to assume that people would assume
that "not set"ing something would be the same as passing zero. For
example, the following two calls produce dramatically different
results:
setcookie('foo', 'bar', $tomorrow);
setcookie('foo', 'bar', $tomorrow, 0, 0);
And I know I'm not alone it this. Buried in the comments on the docs
page (link in my original post above) is someone asking what to pass in
this parameter for a session cookie, and posting that it seemed to work
by passing zero. Another post down lower passes false, which apparently
also works. But neither of them have any idea if their solution works
across different versions of PHP, or if it will continue to be
supported.
Previous Comments:
------------------------------------------------------------------------
[2007-01-07 20:08:27] bjori@php.net
Quote from the setcookie() docs: "time()+60*60*24*30 will
set the cookie to expire in 30 days. If not set, the
cookie will expire at the end of the session (when the
browser closes)."
Note the "If not set" clause (which is essentially the
same as passing 0).
If you believe that sentence can be reworded any better
please share it with us :)
------------------------------------------------------------------------
[2007-01-07 20:04:50] jason191 at herkamire dot com
by "get" I meant "create" not "retrieve" sorry about the ambiguity
there
------------------------------------------------------------------------
[2007-01-07 19:59:47] jason191 at herkamire dot com
This is not a support request.
You might say that it's not "in PHP itself", but that's why I set the
category to "Documentation problem".
I apologize for my grammar, I was not trying to fetch the value of a
cookie, but create one.
I know what setcookie() does, except the API is not fully specified in
the documentation. The documentation should specify what value you can
pass to setcookie() to get a session cookie (rather than a cookie that
expires at a certain date) since it obviously can create session
cookies.
------------------------------------------------------------------------
[2007-01-07 13:06:09] bjori@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
setcookie() _sets_ cookies, it does not retrieve them.
Use the $_COOKIE autoglobal array.
------------------------------------------------------------------------
[2006-12-31 04:28:10] jason191 at herkamire dot com
cleaned up bug title
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39994
--
Edit this bug report at http://bugs.php.net/?id=39994&edit=1