Cookie gets changed when hit comes from a referrer

Νίκος Αλεξόπουλος nikos.gr33k at gmail.com
Tue Oct 8 06:04:34 EDT 2013


# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )

if cookie.get('ID') is not None:
	cookieID = cookie['ID'].value
else:
	cookieID = random.randrange(0, 9999)
	cookie['ID'] = cookieID
	cookie['ID']['path'] = '/'
	print( cookie )

===========
===========

I use this code to retrive or set a cookie to the visitor's browser if 
present and identify him bu it.

All work well except the situation where the user visits my webpage by 
clicking a backlink on another wbpage.

Then for some reason the cookieID changes to another value thus a new 
entry appears into the database when insert happens.

What cna i do about that?



More information about the Python-list mailing list