%hJ^ddlZddlmZddlZdZdadZdZdZdZ	d	Z
d
ZdZdZ
d
Zy)N)	randrangez/home/sultans/tmp/py-sessions/ctjdats]tdd}dt	|zatj
dtttz}t|d}|jtS)NPYSESSIDiisesszw+)	
cookieFunc	getCookie	sessionIdrstr	setCookiefilepathopenclose)randfilenamefiles   4/home/sultans/web/python/demo/5cookie/sessionFunc.pystartSessionrsf$$Z0I(+SY&	Z	2i'&

c8tjdatSNr)rr	r
rrgetSessionIdr)s$$Z0Irc|tstjdatsyt}|||<t	|yNr@You do not have an active web session. Call startSession() firstr
rr		read_file
write_file)namevaluesessionDicts   r
setSessionVarr#3s6
((4	U+KK{rcdtstjdatsi}|St}|Sr)r
rr	r)emptyr"s  rgetSessionVarsr&Cs1
((4	EL+Krctstjdatsyt}|j	|}|S)Nrr)r
rr	rget)r r"r!s   r
getSessionVarr)Ts7
((4	+KOOD!ELrctstjdatsyt}||=t	|y#YxYwrr)r r"s  r
delSessionVarr+ds=
((4	U+KD!{Ds	<Actstjdatsytjdtdttz}t
jj|rtj|yy)Nrri)	r
rr	rr
ospathexistsremove)rs r
endSessionr1vsZ
((4	UIe4)#H	ww~~h
		( rci}ttz}	t|d}|j}|j	|j}|D]"}|j
d}|d}|d}|||<$|S#d}Y?xYw)Nrr=r)r
r
rreadr
splitlinessplit)	dictrrcontentvarsvar	nameValuer r!s	         rrrs
D9$HHc"))+

DIIcN	!!T
	Ks,A66A<cttz}t|d}|jD]\}}|j	|dz|zdz!|jy)Nwr4
)r
r
ritemswriter)r9rrr r!s     rrrsQ9$H#D

e

4#:%,-%	JJLr)r-randomrrr
r
rrr#r&r)r+r1rrrrr<module>rDsG
,	$
 
"
 $"0r