summaryrefslogtreecommitdiff
path: root/modules/user/user.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user/user.module')
-rw-r--r--modules/user/user.module17
1 files changed, 17 insertions, 0 deletions
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, '/');
+ }
+ }
+}