I have used embperl with great success in a number of projects but I
have never needed to keep session information until now and I find
myself a little confused.
Here is the dilemma: I can insert session info into mysql but I am not
sure how to go about restoring session data.
I have a form that has two radio buttons 1: Have a login 2: Need a
login. If the user submits "need" a form opens that accepts a username
and a PIN. After submitting that information I move the user through a
few quiz questions save the data and exit. The %udat works great when
the app is used this way. The problem I have is restoring session data
when I open new pages. The $udat{_session_id} prints out the session
number yet I can not get $udat{User}.
I have a feeling that I need the $r - GetSession somehow but when I use
that [- $r -> GetSession -] I get a
"Can't call method "GetSession" on an undefined value" error.
What do I need to do here???
I have attached the main form and inlined some other relevent snippets.
BTW: when I get this to work I will be more that happy to fully document
what I did post it back here.
Apache 1.3.33, embperl 1.3.6, mod_perl 1.2.9, apache::session 1.6,
apache::sessionX 2.00b5
The Trying to restore session page:
[- use Apache::Session::MySQL; -]
[- use Apache; -]
[- use DBI; -]
[- $req = shift; -]
[- $r -> GetSession; -]
<p> [+ $udat{_session_id} +]</p>
<p> [+ $udat{Token} +]</p>
[- $cookie = $udat{_session_id}; -]

[-  my %session; -]
[- tie %session, 'Apache::Session::MySQL', $cookie, {
      DataSource => 'dbi:mysql:sessions', #these arguments are
      UserName   => 'sessions',         #required when using
      Password   => 'sessions',           #MySQL.pm
      LockDataSource => 'dbi:mysql:sessions',
      LockUserName   => 'sessions',
      LockPassword   => 'sessions'
}; -]
####################################################
httpd.conf options
<Directory "/usr/local/apache/htdocs/">
        PerlSetEnv EMBPERL_OBJECT_BASE base.epl
        PerlSetEnv EMBPERL_OBJECT_APPNAME infosec
        PerlSetEnv EMBPERL_ESCMODE 0
        #PerlSetEnv EMBPERL_OPTIONS 262144
        PerlSetEnv EMBPERL_OBJECT_OPTIONS 16
        #PerlSetEnv EMBPERL_DEBUG 2097152
        #PerlSetEnv EMBPERL_LOG "/tmp/embperl.log"
        PerlSetEnv EMBPERL_SESSION_ARGS
"DataSource=dbi:mysql:session;hostname=localhost UserName=sessions
Password=password"
        PerlSetEnv EMBPERL_SESSION_CLASSES "MySQL Semaphore"
        PerlSetEnv EMBPERL_OBJECT_FALLBACK xerror.html



Notice: This e-mail and any attachments are confidential
and may be subject to legal or some other professional
privilege. They are intended solely for the attention and
use of the named addressee(s). They must not be disclosed
to any person without authorisation.

This e-mail and any attachments are also subject to
copyright. They may only be copied or distributed with
the consent of the copyright owner. If you are not
named addressee you must not use, disclose, retain or
reproduce all or any part of the information contained
in this e-mail or any attachments.
[- $req = shift; -] [- $User = $fdat{User} -] [- $Token = $fdat{Token} -] [- $udat{User} = $User -] [- $udat{Token} = $Token -] [- $HaveLogin = $fdat{Login} -] [$ if $User eq "" && $Token eq "" && $HaveLogin eq "" $]

Starting Out

I have a login


I need to get a login


[$ endif $] [# <----------------------##########################----------------------------> #] [$ if $HaveLogin eq "HaveLogin" $]

[+ $udat{_session_id} +]

[+ $udat{User} +]

Please enter your LAN ID and the PIN.

Please Enter your Lan ID


Please Enter your PIN

Go Back [$ endif $] [# <----------------------##########################----------------------------> #] [$ if $HaveLogin eq "NeedLogin" && $User eq "" && $Token eq "" $]

Please note the following information. You will need it to access the quiz

Please Enter your Lan ID


[- $Token = int( rand 10000000000000 ) -] [- sleep 1; -] [# Check to ensure the password is Unique #] [- $rc = $req->{QuizSelect} -> prepare ("SELECT Token from WebQuiz.User where User.Token = '$Token' " ); -] [- $Val = $rc->execute(); -] [$ if ( $Val == "0E0" ) $] Go Back [$ endif $] [$ endif $] [$ if $User ne "" && $Token ne "" $] [# Check to ensure That the user name's Unique #] [- $rc = $req->{QuizSelect} -> prepare ("SELECT UserName from WebQuiz.User where User.UserName like '$User' " ); -] [- $Val = $rc->execute(); -] [$ if ( $Val == "0E0" ) $] [- $sth = $req->{QuizInsert} -> do ("INSERT INTO WebQuiz.User VALUES('$User','$Token','$udat{_session_id}')" ); -]

User Info: [+ $User +] [+ $Token +]

Please remember this info. You will need it if you have to retake the quiz




Your Information has been submitted. Continue with the quiz.

There are 27 questions please finish the quiz once you begin.

[$ else $]

It looks like you already have a login. Call x7432 for help

[$ endif $] [$ endif $]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to