Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

saving datas on client-side cookie file.

by damian (Beadle)
on Jun 14, 2000 at 13:18 UTC ( [id://18063]=perlquestion: print w/replies, xml ) Need Help??

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

is there a way to save user inputs to the cookie file of the client's browser? instead of creating a temporary file server-side for storing user inputs, i'm going to use the temporary cookie file client-side for storing data's. thanks.
  • Comment on saving datas on client-side cookie file.

Replies are listed 'Best First'.
Re: saving datas on client-side cookie file.
by nashdj (Friar) on Jun 14, 2000 at 15:11 UTC
    What you want to look into is.. CGI::Cookie

    It is, quite simple, and works very well.

    However you really shouldnt try to store too much information in cookies, that isn't what they were designed for. Rather you could use them to store a session ID and then store the necessary data linked by the session ID on the server. But then this doesnt sound like what you had in mind.
Re: saving datas on client-side cookie file.
by c-era (Curate) on Jun 14, 2000 at 15:13 UTC
    It would probably be best to use javascript to save user inputs as a cookie. After the user enters their input you can set the cookie. Later, you can use javascript or perl to grab the cookie. Another way is when the user submits their input have the next page send them a cookie with their info in it. Javascript is more versitial then perl for this, it all depends on how you want it to look/work.
Re: saving datas on client-side cookie file.
by Michalis (Pilgrim) on Jun 14, 2000 at 15:25 UTC
    Sure, with the use of CGI.pm, get some code as an example:
    my $input_cookie=cookie(-name=>'cookie_name', -value=>param('input_name'), -path=>'/', -domain=>'your.domain.com', ); $q=new CGI; print $q->header(-cookie=>$input_cookie);
    Where input_name (used in param) is the name of the form element which contains the data you want to send to the client. The next page, will have the cookie with the name cookie_name available.
Re: saving datas on client-side cookie file.
by wonko (Pilgrim) on Jun 15, 2000 at 10:59 UTC
    You can read more about cookies at the cgi.pm site.

    The full parameter list (from the cgi.pm site:)

    $cookie = $query->cookie(-name=>'sessionID', -value=>'xyzzy', -expires=>'+1h', -path=>'/cgi-bin/database', -domain=>'.capricorn.org', -secure=>1); print $query->header(-cookie=>$cookie);
    To retrieve the cookie in a cgi script and put the value in $cookie_data: $cookie_data=$query->cookie(-name=>'whatever');

    /wonko

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found