Hello Luc

We don't have a published example (and we should put some examples in
the website or the wiki) but it's straightforward. I assume you have
already created the tables supporting the Session package picking from
rivet/packages/session the appropriate SQL script

First of all you have to create the session object in one of the
interpreter initialization scripts then in your scripts serving a
request either in a BeforeScript or within a template, you have to call
the 'activate' method to establish the state of the session. In this
example (as I usually do) I will put the code in the BeforeScript so
that every page will run it

in the apache conf

RivetServerConf ChildInitScript "source myappinit.tcl"
RivetServerConf BeforeScript "source myappbefore.tcl"

within myappinit.tcl put these lines (assuming Mysql is used)

package require Itcl
package require DIO
package require dio_Mysql
package require Session

set dbms [::DIO::handle Mysql \
                -user <dbuser> \
                -db <database> \
                -host localhost]

Session ::SESSION -dioObject              $dbms       \
                  -sessionLifetime        1800        \
                  -sessionRefreshInterval 900         \
                  -entropyFile            /dev/urandom \
                  -entropyLength          10          \
                  -gcProbability          5           \
                  -scrambleCode         \
                        [clock format [clock seconds] -format "%H%M%S"]

change these setting to let them fit your needs. Session class has many
more configuration parameters

in myappbefore.tcl:

::SESSION activate

if {[::SESSION is_new_session]} {

# if the session was created by method activate
# do anything needed to establish the initial state
# of the session. If you're managing logins you probably
# will need to establish the session as initially 'not logged in'

   ::SESSION store status logged_in 0
....
}


Eventually when a child process exits you could configure a
ChildExitScript procedure and destroy the session object along with
other stuff that could have been allocated and also to destroy the DB
connection handle....

if your website is associated to a virtual host the directives should be
placed within the corresponding <VirtualHost ....>...</VirtualHost>
section. You may also consider to have separate virtual interpreters by
setting (at the global level of Apache configuration) also

RivetServerConf SeparateVirtualInterps On

 -- Massimo

On 12/12/2014 01:18 PM, MOULINIER Luc (ILL) wrote:
> Hello !
> 
> I'm a Tcl/Tk user, bue a newbie in Rivet and web server usage. I'd
> like to use the session package and I would appreciate if someone can
> link me to a tutorial on how to use it, or simply some example
> files.
> 
> Many thanks in advance !
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to