Cookie gets changed when page hit comes from a referrer

Cookie gets changed when page hit comes from a referrer

Postby NikosGr » Wed Oct 09, 2013 9:55 pm

Code: Select all
# initialize cookie and retrieve cookie from clients browser
cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] )

if cookie.get('ID') is not None:
   cookieID = cookie['ID'].value
else:
   cookieID = random.randrange(0, 9999)
   cookie['ID'] = cookieID
   cookie['ID']['domain'] = ".superhost.gr"
   cookie['ID']['path'] = '/'
   cookie["ID"]["expires"] = 60*60*24*365      # this cookie will expire in a year

print( cookie )
print( '''Content-type: text/html; charset=utf-8\n''' )



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 can i do about that?
NikosGr
 
Posts: 48
Joined: Thu Mar 28, 2013 6:31 pm
Location: Thessaloniki

Re: Cookie gets changed when page hit comes from a referrer

Postby NikosGr » Thu Oct 10, 2013 1:56 pm

Someone please?
NikosGr
 
Posts: 48
Joined: Thu Mar 28, 2013 6:31 pm
Location: Thessaloniki

Re: Cookie gets changed when page hit comes from a referrer

Postby NikosGr » Fri Oct 11, 2013 11:56 am

hello?? someone can suggest anything?
NikosGr
 
Posts: 48
Joined: Thu Mar 28, 2013 6:31 pm
Location: Thessaloniki

Re: Cookie gets changed when page hit comes from a referrer

Postby stranac » Fri Oct 11, 2013 12:09 pm

There are two possible reasons I can think of why no one is answering:
1. Your problem is not really explained really well. What libraries/modules are you using? How exactly is this code executed?
2. No one knows - this seems like a very specific problem, maybe you would have more luck in a more specialized place.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1212
Joined: Thu Feb 07, 2013 3:42 pm

Re: Cookie gets changed when page hit comes from a referrer

Postby NikosGr » Fri Oct 11, 2013 12:13 pm

from http import cookies is the libray i use:

As for the code and problem i have explained it the best i could.

If you have any questions please feel free to ask me.
NikosGr
 
Posts: 48
Joined: Thu Mar 28, 2013 6:31 pm
Location: Thessaloniki


Return to Web Development

Who is online

Users browsing this forum: No registered users and 1 guest