user_cookie_save

Versions
7
user_cookie_save(array $values, array $fields = array('name', 'mail', 'homepage'))

Saves visitor information as a cookie so it can be reused.

Parameters

$values An array of submitted form values with identifying information about the current user, typically $form_state['values'] from a submit handler.

$fields An array of key values from $values to be saved into a cookie.

▾ 3 functions call user_cookie_save()

comment_form_submit in modules/comment/comment.module
Process comment form submissions; prepare the comment, store it, and set a redirection target.
contact_personal_form_submit in modules/contact/contact.pages.inc
Form submission handler for contact_personal_form().
contact_site_form_submit in modules/contact/contact.pages.inc
Form submission handler for contact_site_form().

Code

modules/user/user.module, line 3281

<?php
function user_cookie_save(array $values, array $fields = array('name', 'mail', 'homepage')) {
  foreach ($fields as $field) {
    if (isset($values[$field])) {
      // Set cookie for 365 days.
      setrawcookie('Drupal.visitor.' . $field, rawurlencode($values[$field]), REQUEST_TIME + 31536000, '/');
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.