[mod_python] Session example and problems.

donnie jones donniejones18 at gmail.com
Tue Mar 1 09:34:38 EST 2005


>From what I can tell, since I am using XMLHttpRequest
to load individual parts of the page, the cookie for the Session
is not getting updated.

I created a "login" page that creates the initial Session and then
goes on to use the other functions, and now the sessions
are working fine with the correct session id throughout each function.

For testing, I set the session expire to 30 seconds.
The problem is that the session keeps expiring, I think that
the XMLHttpRequest must not update the cookie for the session?

Any ideas...?  Is there a way I can manually update the cookie
through python?

Thanks for all the help.
__
Donnie


On Sun, 27 Feb 2005 22:31:00 -0500, Chris Jackson
<christopher.jackson at gmail.com> wrote:
> Ah, i see.
> 
> ~= Chris =~
> 
> On Sun, 27 Feb 2005 22:21:02 -0500, donnie jones
> <donniejones18 at gmail.com> wrote:
> > Well, GetMailboxes is the real function, but
> > UseSession is the test function...
> >
> > It actually seems that the sid I am returning from my GetSid function
> > isn't the actual sid that is in the Cookie, so each time the function is
> > called and I pass my sid, it must think it is a new request and create
> > a new session, that's the best I can figure...
> >
> > So, now I am trying to figure out why I am not getting the correct
> > session id the same as what is in the Cookie.
> >
> > __
> > Donnie
> >
> > On Sun, 27 Feb 2005 21:58:01 -0500, Chris Jackson
> > <christopher.jackson at gmail.com> wrote:
> > > [comments inline]
> > >
> > > On Sun, 27 Feb 2005 21:39:25 -0500, donnie jones
> > > <donniejones18 at gmail.com> wrote:
> > > > Here is the code that calls the UseSession function,
> > > > and it passes the sid that was from the GetSid function
> > > > through the javascript.
> > > >
> > > > xmlhttp=new XMLHttpRequest();
> > > >
> > > > if(xmlhttp2) {
> > > >   url = "mail.py/GetMailboxes?sid=" + sid;
> > > >   xmlhttp2.open("GET", url, true);
> > > > }
> > > >
> > >
> > > hmm, i still don't see the UseSession function. Although I do notice
> > > GetMailboxes:)
> > >
> > > > I have a sneaking suspicion that each req is
> > > > overriding my sess = Session(req, sid) with a new session id
> > > > and it may be because the XMLHttpRequest doesn't pass
> > > > the cookie that is generated for the session to the page,
> > > > and insteach with each calls it thinks a new session should
> > > > be created.
> > > >
> > >
> > > I guess new connections via XMLHttpRequest could be happening,
> > > preventing cookies from being persistent as expected.  I'm not too familiar with
> > > XMLHttpRequest, although your req.write works and displays the correct sid,
> > > so the cookie must be reaching the page.
> > >
> > > And once you have the sid, your good to go, because when using sessions,
> > > data is stored on the server, and the cookie just holds the sid.  you can read
> > > your /tmp/mp_sess* files and watch new session ids being created.
> > >
> > > > I'm working on trying to figure more out...
> > > > __
> > > > Donnie
> > > >
> > >
> > > ~= Chris =~
> > >
> > > > On Sun, 27 Feb 2005 21:29:57 -0500, Chris Jackson
> > > > <christopher.jackson at gmail.com> wrote:
> > > > > Can you paste the line of code where you call UseSession, passing it the sid.
> > > > >
> > > > > ~= Chris =~
> > > > >
> > > > > On Sun, 27 Feb 2005 14:43:38 -0500, donnie jones
> > > > > <donniejones18 at gmail.com> wrote:
> > > > > > The javascript uses XMLHttpRequest and from the responseText is
> > > > > > able to get the SID and pass it to the UseSession function.
> > > > > >
> > > > > > I write out the session id in the UseSession function to make sure
> > > > > > that the same session id is being passed, and it works.
> > > > > > However, when I pass that same session id to the Session(req, sid)
> > > > > > it creates another session...
> > > > > >
> > > > > > __
> > > > > > Donnie
> > > > > >


More information about the Mod_python mailing list