1

If I have not set any life time in cookies then what is the default life time in cookie?

for e.g

setcookie("cookiename", $value);

5 Answers5

6

When you create a cookie via PHP, the default value for its expiration date is 0, which means that the cookie expires when you close the tab from the manual:

If set to 0, or omitted, the cookie will expire at the end of the session (when your browser closes)

Otherwise, you can set the cookies lifetime in seconds as the third parameter:

http://www.php.net/manual/en/function.setcookie.php

IPSDSILVA
  • 1,667
  • 9
  • 27
Roopendra
  • 7,674
  • 16
  • 65
  • 92
1

From the documentation:

expire

If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

Community
  • 1
  • 1
Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
1

cookies with example

If the parameter is not set, the cookie will expire at the end of the session (when the browser closes)..

Bhushan
  • 6,151
  • 13
  • 58
  • 91
1
When you create a cookie via PHP Default Value is 0

If set to 0, or omitted, the cookie will expire at end of the session 
ie when the browser  closes
Arun
  • 19
  • 1
0

If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

http://php.net/manual/en/function.setcookie.php

Paul Dessert
  • 6,363
  • 8
  • 47
  • 74