You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-user@tcl.apache.org by Ronnie Brunner <ro...@netcetera.ch> on 2003/11/14 19:43:30 UTC

Re: Session id

Jerry

> Can someone clarify on how exactly does the websh file context
> session management work? 
> 
> Here is the sample code:
> 
> [code]
> web::filecontext state -path [file join [config::cget stateDirectory] %s] -attachto sid -idgen "idGenerator nextval" 
> [code]
> 
> If I include this code into every page, will the session id number
> increase for every request of the user or the sid won't change at
> all if sid is defined in the querystring? 

Almost: the filecontext defines tha path for the state files,
tells websh to look for the session id in the url param sid and
defines a command to create a unique session id
The idGenerator has to be defined still (does not have to be an
increasing integer but could be anything)

If it is created with [web::filecounter idGenerator -filename
/tmp/sid.seq] it will create increasing numbers for session ids. but
you can provide your own generator. (Just write a proc that returns a
new session id and supply it with the -idgen option)

To actually pass the sid parameter from request to request, use
web::dispatch -track sid

and to really get a new session or load an existing ession use the
corresponding commands of the filecontext (in the example above you
created "state", so state::init state::new etc ... will be the
commands you need).

See

    http://tcl.apache.org/websh/quickref/command_dispatching_and_session_management.html#session_management
    http://tcl.apache.org/websh/examples.ws3#83
    http://tcl.apache.org/websh/quickref/context_handling.html#web::filecontext

Regards
Ronnie

PS: Please try to send mail to the websh-user@tcl.apache.org and not
directly to me only.
----------------------------------------------------------------------
Ronnie Brunner                             ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75

Re: Session id

Posted by Ronnie Brunner <ro...@netcetera.ch>.
> ok, correct me if I'm wrong.
> 
> The option -idgen is used only if filecontext cannot find the parameter sid
> from the url?

No. -idgen is used, if you instruct filecontext to create a new
session id. 
If no id is in the URL (which is defined by -attach to) and you don't
want a new context to be created, -idgen has no effect (but you'll
never get a new id)

Regards
Ronnie
----------------------------------------------------------------------
Ronnie Brunner                             ronnie.brunner@netcetera.ch
Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75

Re: Session id

Posted by Jerry Lam <bo...@hotmail.com>.
ok, correct me if I'm wrong.

The option -idgen is used only if filecontext cannot find the parameter sid
from the url?

thx,

Jerry

----- Original Message ----- 
From: "Ronnie Brunner" <ro...@netcetera.ch>
To: "Jerry Lam" <bo...@hotmail.com>
Cc: <we...@tcl.apache.org>
Sent: Friday, November 14, 2003 1:43 PM
Subject: Re: Session id


> Jerry
>
> > Can someone clarify on how exactly does the websh file context
> > session management work?
> >
> > Here is the sample code:
> >
> > [code]
> > web::filecontext state -path [file join [config::cget stateDirectory]
%s] -attachto sid -idgen "idGenerator nextval"
> > [code]
> >
> > If I include this code into every page, will the session id number
> > increase for every request of the user or the sid won't change at
> > all if sid is defined in the querystring?
>
> Almost: the filecontext defines tha path for the state files,
> tells websh to look for the session id in the url param sid and
> defines a command to create a unique session id
> The idGenerator has to be defined still (does not have to be an
> increasing integer but could be anything)
>
> If it is created with [web::filecounter idGenerator -filename
> /tmp/sid.seq] it will create increasing numbers for session ids. but
> you can provide your own generator. (Just write a proc that returns a
> new session id and supply it with the -idgen option)
>
> To actually pass the sid parameter from request to request, use
> web::dispatch -track sid
>
> and to really get a new session or load an existing ession use the
> corresponding commands of the filecontext (in the example above you
> created "state", so state::init state::new etc ... will be the
> commands you need).
>
> See
>
>
http://tcl.apache.org/websh/quickref/command_dispatching_and_session_management.html#session_management
>     http://tcl.apache.org/websh/examples.ws3#83
>
http://tcl.apache.org/websh/quickref/context_handling.html#web::filecontext
>
> Regards
> Ronnie
>
> PS: Please try to send mail to the websh-user@tcl.apache.org and not
> directly to me only.
> ----------------------------------------------------------------------
> Ronnie Brunner                             ronnie.brunner@netcetera.ch
> Netcetera AG, 8040 Zuerich   phone +41 1 247 79 79 fax +41 1 247 70 75
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: websh-user-unsubscribe@tcl.apache.org
> For additional commands, e-mail: websh-user-help@tcl.apache.org
>
>