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.



301
302
303
# File 'lib/queueit_knownuserv3/known_user.rb', line 301

def initialize(cookieJar)
	@cookies = cookieJar
end

Instance Method Details

#getCookie(name) ⇒ Object



305
306
307
308
309
310
311
# File 'lib/queueit_knownuserv3/known_user.rb', line 305

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



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/queueit_knownuserv3/known_user.rb', line 313

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