Cookies again...

3 views
Skip to first unread message

Tamas

unread,
Jul 16, 2008, 10:01:43 AM7/16/08
to web2py Web Framework
Hi,
for some reason I cannot access cookies I set.
I'm setting a cookie in a controller with:

response.cookies['name'] = id
response.cookies['name']['expires'] = 3600

I can see it in the Firefox cookies dialog, so it is actually set and
stored.
However, when I try to access it from another controller (same domain,
same application):

if request.cookies.has_key ('click_keyword_id'):
# some code

the function returns false. I tried to print out the request.cookies
object, here's what I see:

Set-Cookie: session_id_admin=127.0.0.1.1216145449.188894980676
Set-Cookie: session_id_myapp=127.0.0.1.1216144890.961886533723

So it effectively does not see the cookie.
Can someone help what might be the problem?
Thanks in advance!

Tamas

unread,
Jul 16, 2008, 10:31:19 AM7/16/08
to web2py Web Framework
Sorry for talking to myself...
The solution to my problem was to set the path of the cookie to '/' so
that all scripts could access it.
Like this, after setting the expire time:

response.cookies['name']['path'] = '/'

Tadaa! :)

Massimo Di Pierro

unread,
Jul 16, 2008, 6:17:18 PM7/16/08
to web...@googlegroups.com
Would you write a page on AlterEgo about this with sample code? It
may actually make it in the manual with an acknowledgment.

Massimo

Tamas

unread,
Jul 17, 2008, 8:26:07 AM7/17/08
to web2py Web Framework
Sure, let me know how to proceed about it.

On Jul 17, 12:17 am, Massimo Di Pierro <mdipie...@cs.depaul.edu>
wrote:

Massimo Di Pierro

unread,
Jul 17, 2008, 8:38:20 AM7/17/08
to web...@googlegroups.com
On http://mdp.cti.depaul.edu/AlterEgo

at the bottom there is a link that says create new page. The syntax
is markdown (you can google). Once you create the page not the number
of the page from the URL.
You can visit the page at http://mdp.cti.depaul.edu/AlterEgo/default/
show/[number] and you can edit at http://mdp.cti.depaul.edu/AlterEgo/
default/edit/[number]
To save your edit you need a code. The code is "1234". You page will
not appear in the list until I approve it, to avoid spam.

Massimo

Tamas

unread,
Jul 17, 2008, 9:26:33 AM7/17/08
to web2py Web Framework
I added it here:

http://mdp.cti.depaul.edu/AlterEgo/default/show/149

but I didn't need to enter a code to save...

On Jul 17, 2:38 pm, Massimo Di Pierro <mdipie...@cs.depaul.edu> wrote:
> Onhttp://mdp.cti.depaul.edu/AlterEgo
>
> at the bottom there is a link that says create new page. The syntax  
> is markdown (you can google). Once you create the page not the number  
> of the page from the URL.
> You can visit the page athttp://mdp.cti.depaul.edu/AlterEgo/default/
> show/[number] and you can edit athttp://mdp.cti.depaul.edu/AlterEgo/
Reply all
Reply to author
Forward
0 new messages