Including the token in an encrypted cookie - other than the authentication cookie (since they are often shared within subdomains) - and then at the server side matching it (after decrypting the encrypted cookie) with the token in hidden form field or parameter/header for ajax calls mitigates both the issues mentioned above. This works because a sub domain has no way to over-write an properly crafted encrypted cookie without the necessary information such as encryption key.
Wouldn't it be more secure to encrypt the token, store it in the hidden form field, and store the un-encrypted version in a cookie as http-only?
rather than
encrypt the token, store it in a cookie as http-only, and store the unencrypted version in the hidden form field as suggested in the quote above?
[link] [comments]
SOCIAL SHARE CARD GENERATOR