I want to create a webpage which redirects a user if some cookies are previously set by my webpage. Like this: (I am using a jquery cookie plugin)
// get cookies
var email = $.cookie("email_addr");
var postcode = $.cookie("post_code");
if(email != undefined && postcode != undefined) {
// insert cookies into redirect url
var redirect =
"https://docs.google.com/forms/d/1BofVyLFj9-Y2RQ8LxZuaptS071yHDqW4cdZhvvqTNz8/viewform?entry.139029761=" + email +
"&entry.1727046863=" + postcode;
console.log(redirect);
}
(URL character replacement omitted for readability)
Can I assume the cookies are safe, and are cannot be modified by anyone but the user and the application, so xss attacks are not possible, or do I need to validate them anyway?
I will validate the cookies when they are set, my question is if I can trust my own cookies.