Skip to content

Instantly share code, notes, and snippets.

@midoriberlin
Created September 24, 2015 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save midoriberlin/fb88b0112bbc9677780a to your computer and use it in GitHub Desktop.
Save midoriberlin/fb88b0112bbc9677780a to your computer and use it in GitHub Desktop.
Setting a cookie
@ak5
Copy link

ak5 commented Mar 1, 2016

this will set the expiry date 1 month past the epoch.

I believe you forgot a time() call in the 3rd param like so:

setcookie( $v_username, $v_value, time() + 30 * DAYS_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );

@RexAK
Copy link

RexAK commented May 9, 2017

Additionally, the constant is singular: DAY_IN_SECONDS <----correct vs. DAYS_IN_SECONDS <---- incorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment