Prevent users from logging in to the site if they have not yet accepted cookies.

Should this only be done for IP addresses within the restricted zone, or for everyone ?

Comments

budda’s picture

Implemented a user login form alter to add in a validation callback and display a message to the visitor about why they cannot log in.
Removed all submit handlers to prevent any authentication being done.

budda’s picture

Need a decent way to resolve if a user is accessing the site from within any of the specified countries in the cookiecontrol_countries variable, but from the PHP server side. Best idea anyone?

budda’s picture

The answer is:

echo var_export(unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$_SERVER['REMOTE_ADDR'])));
budda’s picture

Status: Active » Fixed

Implemented cookiecontrol_userinrestrictedcountry() to return true / false if the visitor is from a restricted country.
if they are, then cookies consent must be given in order to log in.

vali hutchison’s picture

Re: #1 - The validation callback preventing user login doesn't cover all login forms - eg where $form_id is user_login at the /user URL.

something like this would cover it:

function cookiecontrol_form_alter(&$form, &$form_state, &$form_id) {
  if ($form_id == 'user_login') {
    if ($s = cookiecontrol_userinrestrictedcountry()) {
      if (!isset($_COOKIE[cookiecontrol_generatesitecookie()]) || $_COOKIE[cookiecontrol_generatesitecookie()] != 'yes') {
        $form['#validate'] = array('cookiecontrol_user_login_ban');
				
         // Remove any existing submit handlers to prevent any authentication taking place
         unset($form['#submit']);
      }
    }  
  }
}
budda’s picture

Status: Fixed » Needs review
alexanderpas’s picture

AFAIK functional essential cookies are exempt from the cookie law.

Login, shopping carts and cookie control settings are examples of functional essential cookies.

Please allow a setting for the webmasters to allow functional essential cookies, without requiring the end user to consent to all cookies.

jorrit’s picture

I agree with this.