Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active October 22, 2015 02:51
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 tommcfarlin/8ab66de5f9f5e25fefec to your computer and use it in GitHub Desktop.
Save tommcfarlin/8ab66de5f9f5e25fefec to your computer and use it in GitHub Desktop.
[WordPress] Set Cookies in WordPress
<?php
/* Assume all validation and verification of the username has been completed
* and that the username is stored in the $username variable.
*
* Note also that the DAY_IN_SECONDS is a constant provided by WordPress
* so we're setting the cookie for one week.
*/
setcookie( 'acme_username', $username, time() + ( 7 * DAY_IN_SECONDS ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment