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.



286
287
288
# File 'lib/queueit_knownuserv3/known_user.rb', line 286

def initialize(cookieJar)
  @cookies = cookieJar
end

Instance Method Details

#getCookie(name) ⇒ Object



290
291
292
293
294
295
296
# File 'lib/queueit_knownuserv3/known_user.rb', line 290

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

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



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/queueit_knownuserv3/known_user.rb', line 298

def setCookie(name, value, expire, domain)
  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 }
      else
        @cookies[key] = { :value => value, :expires => expire }
      end
    end   
  else
    if(deleteCookie)
      @cookies.delete(key, :domain => domain)        
    else
      if(noExpire)
        @cookies[key] = { :value => value, :domain => domain }    
      else
        @cookies[key] = { :value => value, :expires => expire, :domain => domain }    
      end
    end   
  end    
end