change name of cookie;using stringified JSON for cookie value
refactor