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.



266
267
268
# File 'lib/queueit_knownuserv3/known_user.rb', line 266

def initialize(cookieJar)
	@cookies = cookieJar
end

Instance Method Details

#getCookie(name) ⇒ Object



270
271
272
273
274
275
276
# File 'lib/queueit_knownuserv3/known_user.rb', line 270

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



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/queueit_knownuserv3/known_user.rb', line 278

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