|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
does any one know how to use cookie in perl...
can teach me how to create the cookie in one page & the other page will know that the cookie had being created...eg other page can just use if($cookie) to koe if this person entering is authenticated |
|
#2
|
|||
|
|||
|
I recommend you to use cookie-lib.pl
http://www.egr.uri.edu/~kovacsp/cookie-lib/ |
|
#3
|
|||
|
|||
|
pepe thank for telling mi about the website..
but still I dont understand how can I use the script? the cgi-lib & cookie-lib is text file... how do i download & put it in in order to use it??pls help mi once again...thank!! |
|
#4
|
|||
|
|||
|
Download cookie-lib.txt, rename it to cookie-lib.pl and upload it to your cgi-bin directory.
You can use this library from your perl script by putting: require "cookie-lib.pl"; line in your script. You can see syntax for using it at above link. Here is simple script.cgi that reads cookie called "idcheck", and if cookie does not match your variable it sets the cookie. <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> #!/usr/bin/perl require "cookie-lib.pl"; &get_cookie; if ($cookie{'idcheck'} eq "oldvisitor" ) { print "Location: <A HREF="http://www.mydomain.com/index.htmlnn";" TARGET=_blank>http://www.mydomain.com/index.htmlnn";</A> } else{ $cookie{'idcheck'} = $FORM{'oldvisitor'}; &set_cookie(1026432000, ".mydomain.com","/",0); print "Location: <A HREF="http://www.mydomain.com/welcome.htmlnn";" TARGET=_blank>http://www.mydomain.com/welcome.htmlnn";</A> } [/code] [This message has been edited by Pepe (edited November 29, 2000).] |
|
#5
|
|||
|
|||
|
pepe i had downloaded the cookie-lib.txt & had renamed it with cookie-lib,pl....
ANd try with the script you had wrote.. but it did not work & prompt the error >>> cookie-lib.pl did not return a true value at script.cgi at line2. >>> Name "main::FORM" use only once: possible typo at script.cgi at line8. Pls give me some comment on the error....thank |
|
#6
|
|||
|
|||
|
I had one error in previous code. This one works, I tried it, just change URLs to your own.
First time visitors will see /index.shtml and all returning visitors will go to /index.shtml <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> #!/usr/bin/perl require "cookie-lib.pl"; &get_cookie; if ($cookie{'idcheck'} eq "oldvisitor" ) { print "Location: <A HREF="http://www.upitnik.net/index.shtmlnn";" TARGET=_blank>http://www.upitnik.net/index.shtmlnn";</A> } else { $cookie{'idcheck'} = "oldvisitor"; &set_cookie(1026432000, ".upitnik.net","/",0); print "Location: <A HREF="http://www.upitnik.net/index2.shtmlnn";" TARGET=_blank>http://www.upitnik.net/index2.shtmlnn";</A> } [/code] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > cookie!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|