Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Recommended modules for handling cookies?

by Anonymous Monk
on Mar 29, 2000 at 02:45 UTC ( [id://6381]=note: print w/replies, xml ) Need Help??


in reply to Recommended modules for handling cookies?

OK, say my address is: http://sub.domain.com. When setting cookie, what do I use for a domain address? domain.com, .domain.com, sub.domain.com, or .sub.domain.com? And to get a cookie, I use the $ENV{HTTP-COOKIE} command/variable, right?

Replies are listed 'Best First'.
RE: Re: Recommended modules for handling cookies?
by btrott (Parson) on Mar 29, 2000 at 02:49 UTC
    Just try using "sub.domain.com" as the domain. If that's what your domain always is (ie. you don't have other domains like "foo.domain.com" that you want to set the same cookie for), just use that.

    And it's "HTTP_COOKIE", not "HTTP-COOKIE". It's an underscore ("_").

    And, finally, you really should be using CGI::Cookie. From the docs:

    To set cookies:

    # Create new cookies and send them $cookie1 = new CGI::Cookie(-name=>'ID',-value=>123456); print header(-cookie=>[$cookie1]);
    To fetch cookies:
    %cookies = fetch CGI::Cookie; $id = $cookies{'ID'}->value;
    Read the documentation for more info, particularly on setting the domain (look at the code setantae posted).
RE: Re: Recommended modules for handling cookies?
by setantae (Scribe) on Mar 29, 2000 at 02:47 UTC
    I don't want to sound patronising here, but are you sure that's a subdomain and not a host?

    Let's assume it's a host, so your domain is really domain.com, so that's what you put in for the domain.
    To retrieve a cookie, leave out the -value part if you're using the above method.

    setantae@eidosnet.co.uk|setantae|www.setantae.uklinux.net

RE: Re: Recommended modules for handling cookies?
by plaid (Chaplain) on Mar 29, 2000 at 02:49 UTC
    Straight from the CGI::Cookie man page
    2. domain This is a partial or complete domain name for which the cookie is valid. The browser will return the cookie to any host that matches the partial domain name. For example, if you specify a domain name of ".capricorn.com", then Netscape will return the cookie to Web servers running on any of the machines "www.capricorn.com", "ftp.capricorn.com", "feckless.capricorn.com", etc. Domain names must contain at least two periods to prevent attempts to match on top level domains like ".edu". If no domain is specified, then the browser will only return the cookie to servers on the host the cookie originated from.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://6381]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-19 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found