Handling Cookies in Drupal

Last modified: 
Thursday, October 8th, 2015

Working with cookies in Drupal 7

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

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

// Delete the cookie
user_cookie_delete('key');
?>


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.