Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Cookies Help

by ACJavascript (Acolyte)
on Dec 10, 2002 at 01:06 UTC ( [id://218706]=perlquestion: print w/replies, xml ) Need Help??

ACJavascript has asked for the wisdom of the Perl Monks concerning the following question:

Hy perl monks, I need help creating a cookie and reading it.
Heres my code what am i doing wrong?????

$FORM{'username'} == the persons username...
___________
$Data = {'HTTP_COOKIE'}; ($Name,$info) = split(/=/,$Data); if($Name eq $FORM{'username'}){ &WelcomeUser; }else{ $CookieName=$FORM{'username'}; print "Set-Cookie: Name=$CookieName;\n"; &WelcomeAndRedirect; }


_____________

Help please :)
A*C

Replies are listed 'Best First'.
Re: Cookies Help
by Ovid (Cardinal) on Dec 10, 2002 at 01:27 UTC

    You probably should check out the documentation for CGI.pm cookie handling. I'd also recommend reading through my CGI course (link at bottom).

    use CGI qw(:standard); # reading a cookie my $cookie_value = cookie( $cookie_name ); # creating a cookie my $cookie = cookie( -name => $cookie_name, -value=> $some_value ); # And setting the cookie (while printing the header) print header( -cookie => $cookie );

    The above is a simple example of how to do this. Read the docs for more information about how it works.

    Cheers,
    Ovid

    New address of my CGI Course.
    Silence is Evil (feel free to copy and distribute widely - note copyright text)

      Hey thanks alot,,, but dont you need a module to use CGI.pm,, ??? or am i totaly wrong..hehehe
        yeah, but at this point, CGI.pm is pretty much standard. do something like this to create a cookie:

        use CGI;
        
        $q = new CGI;
        my $cookie1 = $q->cookie(-name => 'test', -value => 'test');
        print $q->header(-cookie => $cookie1); 
        
        create multiple cookies like so: -cookie => [$cookie1, $cookie2]
Re: Cookies Help
by dingus (Friar) on Dec 10, 2002 at 08:23 UTC
    Re: Receiving Cookie Values contains the hints I gave the last time this kind of question was asked.

    use CGI or die; is also required reading for this topic :)

    Dingus


    Enter any 47-digit prime number to continue.
      Thanks alot!!!!!!!!!!! guys/gals... :)


      A*C

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-07-13 07:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.