By Borek-1 on
Dear friends, I need to provide "remember me" checkbox for anonymous users so that they don't need to fill in their contact information again and again. I quickly developed the following module:
/**
* Implementation of hook_comment().
*/
function remember_me_comment($comment, $op) {
if (($op == 'update') || ($op == 'insert')) {
if ($comment['remember_me']) {
// store user information into SESSION array
}
else {
unset($_SESSION['comment_anon']);
}
}
}
/**
* Implementation of hook_form_alter().
*/
function remember_me_form_alter($form_id, &$form) {
if ($form_id == 'comment_form') {
if (!$GLOBALS['user']->uid) {
$form['remember_me'] = array(
'#type' => 'checkbox',
'#title' => t('Remember me'),
'#default_value' => 1,
'#weight' => -20
);
}
if (isset($_SESSION['comment_anon'])) {
$form['name']['#default_value'] = $_SESSION['comment_anon']['name'];
//etc.
}
}
}
Should work but when the cache is enabled, even completely another anonymous user can see these saved settings because they will be brought from cache rather from SESSION array. This is very unpleasant and even dangerous because e-mail can be considered confidential information.
Don't you know how to solve this issue? "Remember me" is very important usability feature...
Thanks, Borek
-------------------
Did you hear about Wordpress to Drupal migration module?