def set_device_cookie_and_return_bool(cls, force=''):
 if (force != ''):
  device_cookie = force
 elif (cls.request.get('device') == ''):
  device_cookie = str(read_cookie(cls, 'dvc'))
  if ((not device_cookie) or (device_cookie == 'None') or (device_cookie == '')):
   if get_device(cls)['is_mobile']:
    device_cookie = 'mobile'
   else:
    device_cookie = 'desktop'
 else:
  device_cookie = cls.request.get('device')
 write_cookie(cls, 'dvc', str(device_cookie), '/', 1209600)
 return (device_cookie == 'mobile')

def set_device_cookie_and_return_bool ( cls , force = '' ) : if ( force != '' ) : device_cookie = force elif ( cls . request . get ( 'device' ) == '' ) : device_cookie = str ( read_cookie ( cls , 'dvc' ) ) if ( ( not device_cookie ) or ( device_cookie == 'None' ) or ( device_cookie == '' ) ) : if get_device ( cls ) [ 'is_mobile' ] : device_cookie = 'mobile' else : device_cookie = 'desktop' else : device_cookie = cls . request . get ( 'device' ) write_cookie ( cls , 'dvc' , str ( device_cookie ) , '/' , 1209600 ) return ( device_cookie == 'mobile' )
set a cookie for device returning a dict and set cookie cookie value has to be "mobile" or "desktop" string .