Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70850 > unrolled thread
| Started by | Ferrous Cranus <nikos.gr33k@gmail.com> |
|---|---|
| First post | 2014-05-02 01:11 -0700 |
| Last post | 2014-05-02 09:15 -0700 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
Cookie not retrieving as it should in some cases Ferrous Cranus <nikos.gr33k@gmail.com> - 2014-05-02 01:11 -0700
Re: Cookie not retrieving as it should in some cases alister <alister.nospam.ware@ntlworld.com> - 2014-05-02 08:19 +0000
Re: Cookie not retrieving as it should in some cases Φώντας Λαδοπρακόπουλος <nikos.gr33k@gmail.com> - 2014-05-02 01:45 -0700
Re: Cookie not retrieving as it should in some cases Φώντας Λαδοπρακόπουλος <nikos.gr33k@gmail.com> - 2014-05-02 09:15 -0700
| From | Ferrous Cranus <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2014-05-02 01:11 -0700 |
| Subject | Cookie not retrieving as it should in some cases |
| Message-ID | <e32fc1ac-9396-4a6d-948f-321242377826@googlegroups.com> |
# retrieve cookie from client's browser otherwise set it
try:
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE', '') )
cookieID = cookie['ID'].value
except:
cookieID = str( time.time() )
cookieID = cookieID[-3:]
cookie['ID'] = cookieID
Many times i noticed that the script instead of retrieving the cookie ID value so to identify each visitor uniquely it insteads set its again.
The same think also happens when someone comes to superhost.gr via a link from anothwe webpage
can somebody tell me why this is happening?
is there some flaw in my code? Perhaps it can be written more efficiently?
[toc] | [next] | [standalone]
| From | alister <alister.nospam.ware@ntlworld.com> |
|---|---|
| Date | 2014-05-02 08:19 +0000 |
| Message-ID | <AyI8v.213287$Ey6.209207@fx24.am4> |
| In reply to | #70850 |
On Fri, 02 May 2014 01:11:05 -0700, Ferrous Cranus wrote:
> # retrieve cookie from client's browser otherwise set it try:
> cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE', '') )
> cookieID = cookie['ID'].value
> except:
> cookieID = str( time.time() )
> cookieID = cookieID[-3:]
>
> cookie['ID'] = cookieID
>
>
> Many times i noticed that the script instead of retrieving the cookie ID
> value so to identify each visitor uniquely it insteads set its again.
> The same think also happens when someone comes to superhost.gr via a
> link from anothwe webpage
>
> can somebody tell me why this is happening?
> is there some flaw in my code? Perhaps it can be written more
> efficiently?
I had a similar issue when using Beaker middleware for WSGI which was
caused by me not specifying a location for the storage of the cookie
database.
--
There is a multi-legged creature crawling on your shoulder.
-- Spock, "A Taste of Armageddon", stardate 3193.9
[toc] | [prev] | [next] | [standalone]
| From | Φώντας Λαδοπρακόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2014-05-02 01:45 -0700 |
| Message-ID | <53102702-028a-4885-990b-24ac2a693f9a@googlegroups.com> |
| In reply to | #70851 |
Τη Παρασκευή, 2 Μαΐου 2014 11:19:44 π.μ. UTC+3, ο χρήστης alister έγραψε: > I had a similar issue when using Beaker middleware for WSGI which was > caused by me not specifying a location for the storage of the cookie > database. I have tried also to set the path of the cookie and the expiration date of the cookie so for them not to impose a problem but yet the situation remains the same. # retrieve cookie from client's browser otherwise set it try: cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] ) cookieID = cookie['ID'].value except KeyError: cookieID = str( time.time() ) cookieID = cookieID[-3:] cookie['ID'] = cookieID cookie['ID']['path'] = '/' cookie['ID']['expires'] = 3600 * 24 * 365 # 1 year from now print( cookie.output() ) # send cookie to web client before headers The cookie is properly set in my Chrome browser as i see form Chrome settings. If someone visits for example ypsilandio.gr and then clicks superhost.gr from there then another cookie is also set with the same name 'ID' cusing a mess to the database hwich iam storing the visitor's based on the cookie i'am tryign to retrive from them.
[toc] | [prev] | [next] | [standalone]
| From | Φώντας Λαδοπρακόπουλος <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2014-05-02 09:15 -0700 |
| Message-ID | <790afedc-7c5e-4a7c-96a2-cd423e6874e2@googlegroups.com> |
| In reply to | #70852 |
Τη Παρασκευή, 2 Μαΐου 2014 11:45:10 π.μ. UTC+3, ο χρήστης Φώντας Λαδοπρακόπουλος έγραψε: > Τη Παρασκευή, 2 Μαΐου 2014 11:19:44 π.μ. UTC+3, ο χρήστης alister έγραψε: > > > > > I had a similar issue when using Beaker middleware for WSGI which was > > > caused by me not specifying a location for the storage of the cookie > > > database. > > > > I have tried also to set the path of the cookie and the expiration date of the cookie so for them not to impose a problem but yet the situation remains the same. > > > > # retrieve cookie from client's browser otherwise set it > > try: > > cookie = cookies.SimpleCookie( os.environ['HTTP_COOKIE'] ) > > cookieID = cookie['ID'].value > > except KeyError: > > cookieID = str( time.time() ) > > cookieID = cookieID[-3:] > > > > cookie['ID'] = cookieID > > cookie['ID']['path'] = '/' > > cookie['ID']['expires'] = 3600 * 24 * 365 # 1 year from now > > print( cookie.output() ) # send cookie to web client before headers > > > > The cookie is properly set in my Chrome browser as i see form Chrome settings. > > > > If someone visits for example ypsilandio.gr and then clicks superhost.gr from there then another cookie is also set with the same name 'ID' cusing a mess to the database hwich iam storing the visitor's based on the cookie i'am tryign to retrive from them. Someone please suggest something? This it troubling me for months.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web