Class: QueueIt::CookieManager

Inherits:
Object
  • Object
show all
Defined in:
lib/queueit_knownuserv3/known_user.rb

Instance Method Summary collapse

Constructor Details

#initialize(cookieJar) ⇒ CookieManager

Returns a new instance of CookieManager.



366
367
368
# File 'lib/queueit_knownuserv3/known_user.rb', line 366

def initialize(cookieJar)
  @cookies = cookieJar
end

Instance Method Details

#getCookie(name) ⇒ Object



370
371
372
373
374
375
376
# File 'lib/queueit_knownuserv3/known_user.rb', line 370

def getCookie(name)
  key = name.to_sym
  if(!Utils.isNilOrEmpty(@cookies[key]))
    return @cookies[key]
  end
  return nil
end

#setCookie(name, value, expire, domain, isHttpOnly, isSecure) ⇒ Object



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/queueit_knownuserv3/known_user.rb', line 378

def setCookie(name, value, expire, domain, isHttpOnly, isSecure)
  key = name.to_sym
  noDomain = Utils.isNilOrEmpty(domain)
  deleteCookie = Utils.isNilOrEmpty(value)
  noExpire = Utils.isNilOrEmpty(expire)

  if(noDomain)
    if(deleteCookie)
      @cookies.delete(key)
    else
      if(noExpire)
        @cookies[key] = { :value => value, :httponly => isHttpOnly, :secure => isSecure }
      else
        @cookies[key] = { :value => value, :expires => expire, :httponly => isHttpOnly, :secure => isSecure }
      end
    end
  else
    if(deleteCookie)
      @cookies.delete(key, :domain => domain)
    else
      if(noExpire)
        @cookies[key] = { :value => value, :domain => domain, :httponly => isHttpOnly, :secure => isSecure }
      else
        @cookies[key] = { :value => value, :expires => expire, :domain => domain, :httponly => isHttpOnly, :secure => isSecure }
      end
    end
  end
end