[mod_python] Conflit with same different Session IDs

S.R.Pardá linux at qbox.es
Fri Dec 21 11:06:14 EST 2007


hI, 

Sorry to post again. 


I don't understand why session are not retrived , after change the path.


This is what I have done:

   <Directory "/home/user/appA/"> 
	PythonOption mod_python.session.application_path "/appA"
   </Directory>

or 

   <Location /appA>
	PythonOption mod_python.session.application_path /appA
   </Location>


And now I see the cookies in firefox have the path "appA". Ok.



When I test in a psp page:

	Session received: <%=str(dict(session))%> <br>
	<%
	# Set the session for next time
	session['TEST'] = 'Ok'
	%>
	Sesion set: <%=str(dict(session))%> <br>


The output the first time is what was expected:

	Session received: {}
	Session set: {'TEST':'Ok'}

the second time is the same when, the session received should be
{'TEST':'Ok'}. But the output was:

	Session received: {}
	Session set: {'TEST':'Ok'}



If I disable the application_path , all works fine. 

One stupid question:

¿ Is There something I should know ? 

Of course, because otherwise it would work. I'm reading session
documentation, but don't see nothing. 
I have test with session.load and session.save nd other things.




Thank You

	S.R.Parda



El vie, 21-12-2007 a las 14:17 +0100, S.R.Pardá escribió:
> Hi again.
> 
> Ok, now the cookies have an app path for every key. And data is not
> shared between applications.
> 
> 
> I have added the PythonOption  in the two apps.
> But now the It seems the data is not retrieved after.
> 
> 
> When I check with:
> 
> 	seesion.has_key('user')
> 
>  ¿ Its necesary access it with 	seesion.has_key('apppath/user') ?
> 
> 
> 
> Thank You
> 
> 
> 	S.R.Parda
> 
> 
> 
> El vie, 21-12-2007 a las 10:52 +1100, Graham Dumpleton escribió:
> > Or use a cookie path. See:
> > 
> >   http://www.modpython.org/live/current/doc-html/pyapi-sess-classes.html
> > 
> > In particular:
> > 
> >   mod_python.session.application_path
> > 
> > option.
> > 
> > Ensure this option is set differently for each application URL context
> > using Location directive.
> > 
> > Graham
> > 
> > On 21/12/2007, Greg Fawcett <greg at vig.co.nz> wrote:
> > > If your sessions rely on cookies (most do) then you can resolve your session
> > > conflicts by using different domains - this will force browsers (all
> > > browsers - you probably need to cater for more than just Firefox) to create
> > > a new cookie/session. So set up appa.mydomain.co.nz for appa, and
> > > appb.mydomain.co.nz for appb.
> > >
> > > I think your first question about module names and sessions should wait for
> > > wiser heads than mine, but I doubt that it is the module conflict that is
> > > breaking pickle in sessions.
> > >
> > > Cheers!
> > > Greg.
> > >
> > >
> > > On 21/12/2007, S.R.Pardá <linux at qbox.es> wrote:
> > > > Hi.
> > > >
> > > > 1.- I will explain what I'm doing to understand me better:
> > > >
> > > > I'm trying to have various modpython applications that shared some
> > > > modules (like libraries) and with others modules with little
> > > > differences.
> > > > I wrote about problems with module names coincidence between
> > > > applications.
> > > > Using import_module seems capable of load them when needed, but losing
> > > > the pickle abbility for using session for data persistence.
> > > >
> > > > Now, I have modified the modules path, so modules shared among
> > > > applications now resides in different packages so I import them with:
> > > >
> > > >         from appApack import users
> > > > or
> > > >         from appBpack import users
> > > >
> > > > And modpython apache session now works ok.
> > > >
> > > > ¿ Do you think thats is well done ?
> > > >
> > > >
> > > >
> > > >
> > > > 2.- Now I realized of one hidden problem appears that i haven't in
> > > > count:
> > > >
> > > > Because in Firefox the same session ID is used for different tab and
> > > > browsers. Data stored in sessions, is used between applications.
> > > >
> > > > So, if I store an instance of class User in session['activeUser'], it is
> > > > retrieved by application A and application B.
> > > >
> > > > But now, I received an error, when application B, try to retrieve an
> > > > object from session['activeUser']:
> > > >
> > > >         ImportError: No module named appApack.users
> > > >
> > > > That's because when it tries to retrieve an user of appBpack instead it
> > > > receives an instance of class User in appApack stored in the session
> > > > with the same name 'activeUser'.
> > > >
> > > > Now the error is obvious, because the pack A doesn't exist in
> > > > application B paths, and I use the import.
> > > > Previously I tried with import_module and received an error trying to
> > > > import  _mp_62617189222202272 , that was not so clear. So I discarted
> > > > import_module.
> > > >
> > > >
> > > >
> > > > ¿ What can I do to solve that problem easily?
> > > >
> > > >         (I know I can prefix all session names with 'AppA_' or 'AppB_')
> > > >
> > > >
> > > > ¿ Can I change session ID handling in Firefox ?
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Mod_python mailing list
> > > > Mod_python at modpython.org
> > > > http://mailman.modpython.org/mailman/listinfo/mod_python
> > > >
> > >
> > >
> > >
> > > --
> > > Phone: +64 3 409 8165
> > > Mobile: +64 21 333 291
> > > Fax: +64 3 974 6810
> > > Web: www.vig.co.nz
> > > _______________________________________________
> > > Mod_python mailing list
> > > Mod_python at modpython.org
> > > http://mailman.modpython.org/mailman/listinfo/mod_python
> > >
> > >
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list