From a5dba069fb404bc0f2999bf2732154c75d5e4f2c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 9 Oct 2009 15:39:12 +0000 Subject: - #440876 by Dave Reid, sun: reuse comment.module's anonymous cookie information for contact forms. --- modules/user/user.module | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'modules/user/user.module') diff --git a/modules/user/user.module b/modules/user/user.module index 6ca3039db..5fcb39e93 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -3226,3 +3226,20 @@ function user_login_destination() { return $destination; } +/** + * Saves visitor information as a cookie so it can be reused. + * + * @param $values + * An array of submitted form values with identifying information about the + * current user, typically $form_state['values'] from a submit handler. + * @param $fields + * An array of key values from $values to be saved into a cookie. + */ +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, '/'); + } + } +} -- cgit v1.2.3