"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/eg/example.perl" (15 Sep 2009, 1394 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 ######################################################################
    2 #
    3 # Consult the documentation before trying to run this file.
    4 # You need a /tmp directory or you need to change the Directory option!
    5 # This file also assumes PerlSendHeader Off.
    6 #
    7 ######################################################################
    8 
    9 use strict;
   10 use Apache;
   11 use CGI;
   12 use Apache::Session::File;
   13 
   14 my $r = Apache->request();
   15 
   16 $r->status(200);
   17 $r->content_type("text/html");
   18 $r->send_http_header;
   19 
   20 my $session_id = $r->path_info();
   21 $session_id =~ s/^\///;
   22 
   23 $session_id = $session_id ? $session_id : undef;
   24 
   25 my %session;
   26 my $opts = { Directory => '/tmp', LockDirectory => 'tmp', Transaction => 1 };
   27 
   28 tie %session, 'Apache::Session::File', $session_id, $opts;
   29 
   30 my $input = CGI::param('input');
   31 $session{name} = $input if $input;
   32 
   33 print<<__EOS__;
   34 
   35 Hello<br>
   36 Session ID number is: $session{_session_id}<br>
   37 The Session ID is embedded in the URL<br>
   38 <br>
   39 Your input to the form was: $input<br>
   40 Your name is $session{name}<br>
   41 
   42 <br>
   43 <a href="http://localhost/example.perl/$session{_session_id}">Reload this session</a><br>
   44 <a href="http://localhost/example.perl">New session</a>
   45 
   46 <form action="http://localhost/example.perl/$session{_session_id}" method="post">
   47   Type in your name here:
   48   <input name="input">
   49   <input type="submit" value="Go!">
   50 </form>
   51 __EOS__