3

l_eJã@spddlZddlmZddlZdZdadd„Zdd„Zd	d
„Zdd„Z	d
d„Z
dd„Zdd„Zdd„Z
dd„ZdS)éN)Ú	randrangez/home/sultans/tmp/py-sessions/ÚcCsNtjdƒatsJtddƒ}dt|ƒatjdtƒtt}t|dƒ}|jƒtS)NÚPYSESSIDi€–˜iÿàõZsessÚw)	Ú
cookieFuncÚ	getCookieÚ	sessionIdrÚstrÚ	setCookieÚfilepathÚopenÚclose)ZrandÚfilenameÚfile©rú4/home/sultans/web/python/demo/5cookie/sessionFunc.pyÚstartSessions


rcCstjdƒatS)Nr)rrrrrrrÚgetSessionId)s
rcCs0tstjdƒatsdStƒ}|||<t|ƒdS)Nrz@You do not have an active web session. Call startSession() first)rrrÚ	read_fileÚ
write_file)ÚnameÚvalueÚsessionDictrrrÚ
setSessionVar3s
rcCs$tstjdƒatsi}|Stƒ}|S)Nr)rrrr)ÚemptyrrrrÚgetSessionVarsCs
rcCs*tstjdƒatsdStƒ}|j|ƒ}|S)Nrr)rrrrÚget)rrrrrrÚ
getSessionVarTs

rc	Cs@tstjdƒatsdStƒ}y
||=WnYnXt|ƒdS)Nrz@You do not have an active web session. Call startSession() first)rrrrr)rrrrrÚ
delSessionVards

rcCsFtstjdƒatsdStjdtdƒtt}tjj|ƒrBtj|ƒdS)Nrz@You do not have an active web session. Call startSession() firsti'iñØÿÿ)	rrrr
rÚosÚpathÚexistsÚremove)rrrrÚ
endSessionvs
r#c	
Csxi}tt}yt|dƒ}|jƒ}|jƒWnd}YnX|jƒ}x.|D]&}|jdƒ}|d}|d}|||<qJW|S)NÚrrú=ré)rrrÚreadr
Ú
splitlinesÚsplit)	ÚdictrrÚcontentÚvarsÚvarZ	nameValuerrrrrr‡s



rcCsJtt}t|dƒ}x*|jƒD]\}}|j|d|dƒqW|jƒdS)Nrr%Ú
)rrrÚitemsÚwriter
)r*rrrrrrrrŸs

r)rÚrandomrrrrrrrrrrr#rrrrrrÚ<module>s