in reply to How do I use HTTP Cookies?

Script Archive has a good library I use, along with good examples I was able to read through and understand. You can use his library to perform function calls for all your cookie management.

Basically, whenever you set a cookie to a user, it has a name and a value. Whenever a user visits you domain, all cookies are passed to your server that were set by your domain.

So if you want to send a cookie, you call the function to set the expiration date at whatever you want, print your http header, and between the two end-of-lines of the header, call the setCookie function. The set function will take a name-value pair (as many as you want to pass) and sets those cookies onto the client.

To remove cookies, you'd do the same as above only set the date for some time in the past. Then it will delete cookies with those names off the client.

To get a cookie, you just call the getCookie function. That returns a true or false if the cookie exists. To get the actual value of the cookie, you would use the line $valueIwant = $Cookies{'cookieName'}; that way you can set multiple cookies to a client and get them.

Again, the README and counter example should help you work through it. Good luck.

Replies are listed 'Best First'.
Re^2: How do I use HTTP Cookies?
by VSarkiss (Monsignor) on Aug 30, 2004 at 16:29 UTC

    I wouldn't recommend MSA scripts -- they have known problems with security (among other things). Instead I'd recommend beginners start with the NMS scripts.