cgi sessions between two Perl scripts -
IM is using two Perl scripts in my website. I got a search field in favor, which calls for the first script The result is written in the output file. With the next click, the user invokes the second script, it reads an output file and creates a config file based on user search. Currently IM is writing on the output file only, but I need to personalize this file with a session id.
I'm trying with CGI: session, but I do not understand that these two Perl scripts I think I need to compare session ID, and for every session Have to write an output file.
What is one of you to do this ??
The first script: write the session in a file:
my $ session = new CGI :: session (undef, $ cgi, {directory => Usr / local / path / "}); Then send the cookie to the client:
My $ cookie = $ cgi- & gt; Cookie (CGISSID => $ session-> ID); Second script: Try to get session ID: $ sid = $ cgi- & gt; Cookie ("CGISACADADIDA") || Undef; Print $ sid
This returns a status: 500 .
You have to pass the session ID in a way that the customer will ask you to Will provide back. This is usually the use of cookies.
use utf8; Use 'open': std ',': encoding (UTF-8) '; Use CGI Cuev (UFF8); Use CGI :: session qw (); CONTINUOUS SESSION_DIR = & gt; '...'; CONTINUOUS SESSION_EXPIRE = & gt; '+ 12h'; # From the last experiment (not generating) my $ cgi = cgi- & gt; new (); My $ session = CGI :: session-> new ('Driver: file', scalar ($ CGI- & gt; cookie ('session_id')), {directory = & gt; session_cir},); $ Session- & gt; Ending (SESSION_EXPIRE); # Whatever your page counted on my $ count = $ session- & gt; The absolute ('counting') does; ++ $ count; $ Session- & gt; Ultimate (calculation = & gt; $ count); My $ content = "This request is $ count"; Print $ cgi- & gt; Header (-type = & gt; 'text / html', -charset = & gt; 'UTF-8', -cookie = & gt; $ cgi- & gt; cookie (-name = & gt; 'session_id' - value = & gt; $ session-> ID, -expier = & gt; SESSION_EXPIRE,)), $ content; There is only one script shown here, but clearly do not stop the two scripts from reaching the same session (if they can reach the same session store).
Comments
Post a Comment