Surprise

2007/09/10

Surprise


Have always thought that I know everyting about cookies and sessions. Now I am having with using php session from django application (trying to use). Of course, the only server I can test it has old django version, so will upgrade Subversion and later we will see what happens. Even in Brno one can play with websites.

Update: nothing fancy, using excellent python module:

Unserialize class for the PHP serialization format. @author Scott Hurring; scott at hurring dot com

@version v0.4 BETAimport PHPUnserialize
import PHPUnserialize

sessiondir = '/tmp'

def get_session_data( PHPSESSID ):
try:
f = open( os.path.join( sessiondir,
'sess_%s'% PHPSESSID ) )
phpsessiondata = f.read()
f.close()

except IOError:
return None
u = PHPUnserialize.PHPUnserialize()
return = u.session_decode( phpsessiondata )




and few settings to use domain wide cookies it could be achieved easily (provided django runs on the same machine as php).

0 comments :