Index: known_user_role.module
===================================================================
--- known_user_role.module	(revision 1207)
+++ known_user_role.module	(working copy)
@@ -59,7 +59,11 @@
  * Clear the cookies.
  */
 function known_user_role_clear() {
-  setcookie('known_user_role_details', '', time()-1000000, '/');
+  $cookiedomain = variable_get('known_user_role_cookie_domain','');
+  if($cookiedomain!='')
+    setcookie('known_user_role_details', '', time()-1000000, '/', $cookiedomain);
+  else
+    setcookie('known_user_role_details', '', time()-1000000, '/');
   cache_clear_all();
   drupal_goto('user');
 }
@@ -225,6 +229,27 @@
   foreach (user_roles() as $rid => $role) {
     $form['role']['#options'][$rid] = $role;
   }
+  $form['cookie_domain'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Known User Cookie Domain'),
+    '#description' => t('Ensure that this text is used across all sites. The domains to which the cookie applies.'.
+      'The usual format will be ".domain.com", and this will cover xxx.domain.com, as well as domain.com.' .
+      'Note that there could be security issues if the domain is too broad. .com or .www will allow the cookie '.
+      'to be accessed from nearly every domain.'),
+    '#default_value' => variable_get('known_user_role_cookie_domain',''),
+    '#size' => 100,
+    '#required' => TRUE,
+  );
+  $form['cookie_lifetime'] = array(
+    '#type' => 'select',
+    '#title' => t('Known User Cookie Lifetime (days)'),
+    '#default_value' => variable_get('known_user_role_cookie_lifetime',30),
+    '#description' => t('Select the lifetime in days for the known user cookie'),
+  );
+  $form['cookie_lifetime']['#options'][1]=7;
+  $form['cookie_lifetime']['#options'][2]=10;
+  $form['cookie_lifetime']['#options'][3]=30;
+  $form['cookie_lifetime']['#options'][4]=365;
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => 'Save',
@@ -239,6 +264,8 @@
 function known_user_role_select_role_form_submit($form, &$form_state) {
   $roles = user_roles();
   variable_set('known_user_role', array($form_state['values']['role'] => $roles[$form_state['values']['role']]));
+  variable_set('known_user_role_cookie_domain',$form_state['values']['cookie_domain']);
+  variable_set('known_user_role_cookie_lifetime', trim($form_state['values']['cookie_lifetime']));
   drupal_set_message(t('Settings saved.'));
 }
 
@@ -252,8 +279,13 @@
 function known_user_role_user($op, &$edit, &$account, $category = NULL) {
   switch ($op) {
     case 'login':
-      //set cookie, expire after 30 days
-      setcookie('known_user_role_details', $account->uid.'|'.$account->profile_first_name, time()+2592000, '/');
+      // Create the login cookie, setting its lifetime in seconds
+      $cookielifetime = 60*60*24 * variable_get('known_user_role_cookie_lifetime',30);
+      $cookiedomain = variable_get('known_user_role_cookie_domain','');
+      if($cookiedomain!='')
+        setcookie('known_user_role_details', $account->uid.'|'.$account->profile_first_name, time() + $cookielifetime, '/', $cookiedomain);
+      else
+        setcookie('known_user_role_details', $account->uid.'|'.$account->profile_first_name, time() + $cookielifetime, '/');
       cache_clear_all();
       break;
   }
Index: README.txt
===================================================================
--- README.txt	(revision 1194)
+++ README.txt	(working copy)
@@ -14,8 +14,15 @@
 Known user role) ... it is advised you create a role specifically for 
 the purpose, if required, and use with care! Default is Anonymous (e.g. 
 for safety it does nothing except a fancy welcome message if you do not 
-set a role). 
+set a role).  
 
+Apply the know user cookie settings in the same path (User management -> 
+Known user role). Here, the cookie lifetime can be set, and the domain
+that is applied to the cookie can be set here too. '.mysite.com' is the
+format that is required, and allows known user cookies to be shared between 
+'part1.mysite.com' and 'part2.mysite.com' for example. Note that this cookie
+domain needs to be consistent across all sites.
+
 In the block admin page (Site building -> Blocks) enable the "Known user 
 login" block in the region you usually show your login block. This block 
 has three states: 
