in reply to cookies n variables

Keep in mind if you're going to be storing information in a cookie, a user can manipulate it.

The safest way to do this, is store your information server side, and create a 'non-determinate' value as the cookie value. Hookup the non-determinate value with the data, and you can map the data between the browser and what you have stored server side.

Replies are listed 'Best First'.
Re: Re: cookies n variables
by Anonymous Monk on Nov 16, 2002 at 10:18 UTC
    You can Encrypt the cookies for safety .... there is a very good example in the MOD_PERL Book about encrypting the cookies Using MD5 and crypt modules
      1. If you encrypt using md5, how do you expect do decrypt?
      2. If you encrypt using another scheme, how do you get back data the user has deleted from the cookie?

      There is only one truely safe way to do this, and that is to maintain state with a cookie (or hidden params) (see previous post). The information stored server side is non-volatile, any information stored in a cookie is volatile and susceptible to tampering/attack/deletion et al.

      Using a session NDV session id makes everything *that* much more safer. Of course there is safe and there is *safe*, and any solution chosen should represent the level of risk allowable for the project.

      For example a site may manage content via a cookie, and default to a default page if the cookie is not found, however a bank may use any combination of challenge/response using a 3rd party token generator (ala secure_id)...

      IMO it is *so* easy to produce a decent level of security with a NDV sess_id, and storing the information server side, why not do it? why put information into a volitile data source?

        You can do a pair of cookies, one with the data. the second md5 hashed with the data and a private string that only your cgi knows. That way when the data cookie is retrived you can take the data cookie returned + the private string, then hash and compair to the md5 cookie you sent. It will tell you if the data has been changed.

        -Waswas