# ============================================================================= # simpsess.ws3 -- example use of session # nca-073-9 # $Id$ # ============================================================================= # ============================================================================= # turn logging on # ============================================================================= web::logfilter add simpsess.-debug web::logdest add simpsess.-debug file [file join .. .. logs simpsess.log] # ============================================================================= # util # ============================================================================= # ============================================================================= # config # ============================================================================= ## parse query-string web::dispatch -cmd "" -postdata "" ## create a number generator web::filecounter idgen -filename [file join .. .. data state.SEQNO] ## and create the context web::filecontext statef -path [file join .. .. data] proc startPage {} { return "\nSimple Session\n\n\n" } proc finishPage {} { return "\n" } web::command showsessioncontext { web::put [startPage] if { [catch {web::statef::load [web::formvar id] } msg] == 1 } { web::put "sorry - cannot load session context
\n" web::put "websh said: $msg
\n" } else { web::putx {

Top secret session information

Id
{web::put [web::statef::id]}
Name
{web::put [web::statef::get name]}
Age
{web::put [web::statef::get age]} } } web::putx {
back} web::put [finishPage] } web::command submitsessioncontext { web::put [startPage] if { [catch {web::statef::new [idgen nextval] } msg] == 1 } { web::put "sorry - session exists
\n" web::put "websh said: $msg
\n" } else { web::putx {

Thank you

Id
{web::put [idgen curval]}
Name
{web::put [web::formvar name ""]}
Age
{web::put [web::formvar age ""]} } } web::putx {
back} web::put [finishPage] web::statef::set name [web::formvar name ""] web::statef::set age [web::formvar age ""] web::statef::commit } web::command newsessioncontext { web::put [startPage] web::putx {
Name
{web::put {}}
Age
{web::put {}}
} web::put [finishPage] } web::command default { web::put [startPage] web::putx {
{ web::put {} }
} web::put "
" web::putx { create session} web::put "
" web::put [finishPage] } set nam [array names env] puts stderr $nam foreach tmp $nam { puts stderr "$tmp $env($tmp)" } web::dispatch -querystring ""