Handling Cookies in Drupal

Last modified: 
Thursday, October 8th, 2015

Working with cookies in Drupal 7

// Set a cookie.
$user_cookie = array('key'=>'value');

// Print the cookie contents from Drupal.visitor.key
print $_COOKIE['Drupal_visitor_key']; //outputs value

// Delete the cookie

The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.