Yes, there is a way. It is called Secure Cookie Protocol .
Are you using SSL correctly? (because if you do not, this whole conversation is pointless).
Well, you encrypt the cookie, but use the SSL session id. Assuming SSL gives you adequate endpoint security (strong ciphers, etc.), SCP should protect your data and let you know when another SSL session tries to use the same cookie (because sessionid is changing, and therefore MAC will change).
key = HMAC(user name|expiration time, secret_key) cookie = user name|expiration time|encrypt(data, key) cookie = cookie | HMAC( user name|expiration time|data|sessionid, key)
Thus, you create a unique verification code based on the SSL session ID.
Note that REMOTE_ADDR or the user agent never affects. The only factors that he uses are things that are extremely non-trivial to substitute if you have not physically compromised the client box ...
source share