I run a Drupal 7 site (currently 7.15) since longer time and have the problem with cookies:
I need 2 cookies for non-Drupal PHP-scripts at my web site.
I set them in the hook_init of my custom module:
/**
* Implements hook_user_login().
*/
function pref_user_login(&$edit, $account) {
if ($account->uid <= 0) {
return;
}
#drupal_set_message('<p>Hello, '.$account->name.'</p>');
$auth = md5(join('_', array($account->uid, MY_SECRET)));
$year = time() + 60 * 60 * 24 * 30 * 12;
setcookie('pref_id', $account->uid, $year, '/', '.preferans.de');
setcookie('pref_auth', $auth, $year, '/', '.preferans.de');
}
The problem is, that I need to set the both cookies each time a logged in user visits the front page and not just when the user logs in.
Does anybody please have an idea how to do it, maybe by JavaScript if I can't do it regular way?