|
List Info
Thread: What is the rule of cookie
|
|
| What is the rule of cookie |

|
2007-05-17 08:53:45 |
Hi all
I am using cherrypy 2.2.1
In code, I can use cherrypy.response.simpleCookie and
cherrypy.request.simpleCookie to set and get the cookie's
value
correctly.
But while I want to delete a cookie, I write this code:
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
The system give me an error
KeyError: 'new_page_name'
I think the cookie is deleted, so I can not get it by the
name.
But why?
--
with kind regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: What is the rule of cookie |
  United States |
2007-05-17 09:43:35 |
ro wrote:
> I am using cherrypy 2.2.1
> In code, I can use cherrypy.response.simpleCookie and
> cherrypy.request.simpleCookie to set and get the
cookie's
> value correctly.
>
> But while I want to delete a cookie, I write this
code:
>
>
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
>
> The system give me an error
See http://www.cherr
ypy.org/wiki/Cookies (which I've just updated). You have
to set the cookie first, then set its expiration time (to
0).
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
|
| Re: What is the rule of cookie |

|
2007-05-17 19:52:32 |
On 5/17/07, Robert Brewer <fumanchu amor.org> wrote:
> ro wrote:
> > I am using cherrypy 2.2.1
> > In code, I can use cherrypy.response.simpleCookie
and
> > cherrypy.request.simpleCookie to set and get the
cookie's
> > value correctly.
> >
> > But while I want to delete a cookie, I write this
code:
> >
> >
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
> >
> > The system give me an error
>
> See http://www.cherr
ypy.org/wiki/Cookies (which I've just updated). You have
to set the cookie first, then set its expiration time (to
0).
Yes, I have set it.
This is my test code :
print
cherrypy.request.simpleCookie['new_page_name'].value
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
You can see that the first request line worked fine. But the
second
line cause error, I am sure that there is no operation will
set the
cookie expires between these two lines.
I think there are some differents between response and
request
cherrypy.response.simpleCookie.has_key('new_page_name')
will return False, but
cherrypy.request.simpleCookie.has_key('new_page_name')
will return True.
--
with kind regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: What is the rule of cookie |

|
2007-05-20 19:58:32 |
On 5/18/07, ro <rosettas gmail.com> wrote:
> On 5/17/07, Robert Brewer <fumanchu amor.org> wrote:
> > ro wrote:
> > See http://www.cherr
ypy.org/wiki/Cookies (which I've just updated). You have
to set the cookie first, then set its expiration time (to
0).
>
> Yes, I have set it.
> This is my test code :
>
> print
cherrypy.request.simpleCookie['new_page_name'].value
>
>
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
>
> You can see that the first request line worked fine.
But the second
> line cause error, I am sure that there is no operation
will set the
> cookie expires between these two lines.
>
> I think there are some differents between response and
request
>
cherrypy.response.simpleCookie.has_key('new_page_name')
> will return False, but
> cherrypy.request.simpleCookie.has_key('new_page_name')
> will return True.
Is there nobody meet same problem?
Did the cookies work fine while you want delete it?
I think I have to rewrite my code to use the session...
--
with kind regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: What is the rule of cookie |
  United States |
2007-05-20 22:24:29 |
On May 17, 5:52 pm, ro <roset... gmail.com> wrote:
> On 5/17/07, Robert Brewer <fuman... amor.org> wrote:
>
> > ro wrote:
> > > I am using cherrypy 2.2.1
> > > In code, I can use
cherrypy.response.simpleCookie and
> > > cherrypy.request.simpleCookie to set and get
the cookie's
> > > value correctly.
>
> > > But while I want to delete a cookie, I write
this code:
>
> > >
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
>
> > > The system give me an error
>
> > Seehttp://www.cherr
ypy.org/wiki/Cookies(which I've just updated). You have
to set the cookie first, then set its expiration time (to
0).
>
> Yes, I have set it.
> This is my test code :
>
> print
cherrypy.request.simpleCookie['new_page_name'].value
>
>
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
>
> You can see that the first request line worked fine.
But the second
> line cause error, I am sure that there is no operation
will set the
> cookie expires between these two lines.
>
> I think there are some differents between response and
request
>
cherrypy.response.simpleCookie.has_key('new_page_name')
> will return False, but
> cherrypy.request.simpleCookie.has_key('new_page_name')
> will return True.
Yes, there are differences. It's important to understand
that the
request cookies are not automatically copied to the response
cookies.
Clients will send the same cookies on every request, and
therefore
cherrypy.request.cookie should be populated each time. But
the server
doesn't need to send the same cookies with every response;
therefore,
cherrypy.response.cookie will usually be empty. When you
wish to
"delete" (expire) a cookie, therefore, you must
set
cherrypy.response.cookie[key] = value first, and then set
its expires
attribute to 0.
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: What is the rule of cookie |

|
2007-05-20 22:29:14 |
On 5/21/07, fumanchu <fumanchu amor.org> wrote:
>
> On May 17, 5:52 pm, ro <roset... gmail.com> wrote:
> > On 5/17/07, Robert Brewer <fuman... amor.org> wrote:
> >
> > > ro wrote:
> > > > I am using cherrypy 2.2.1
> > > > In code, I can use
cherrypy.response.simpleCookie and
> > > > cherrypy.request.simpleCookie to set and
get the cookie's
> > > > value correctly.
> >
> > > > But while I want to delete a cookie, I
write this code:
> >
> > > >
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
> >
> > > > The system give me an error
> >
> > > Seehttp://www.cherr
ypy.org/wiki/Cookies(which I've just updated). You have
to set the cookie first, then set its expiration time (to
0).
> >
> > Yes, I have set it.
> > This is my test code :
> >
> > print
cherrypy.request.simpleCookie['new_page_name'].value
> >
> >
cherrypy.response.simpleCookie['new_page_name']['expires'] =
0
> >
> > You can see that the first request line worked
fine. But the second
> > line cause error, I am sure that there is no
operation will set the
> > cookie expires between these two lines.
> >
> > I think there are some differents between response
and request
> >
cherrypy.response.simpleCookie.has_key('new_page_name')
> > will return False, but
> >
cherrypy.request.simpleCookie.has_key('new_page_name')
> > will return True.
>
> Yes, there are differences. It's important to
understand that the
> request cookies are not automatically copied to the
response cookies.
> Clients will send the same cookies on every request,
and therefore
> cherrypy.request.cookie should be populated each time.
But the server
> doesn't need to send the same cookies with every
response; therefore,
> cherrypy.response.cookie will usually be empty. When
you wish to
> "delete" (expire) a cookie, therefore, you
must set
> cherrypy.response.cookie[key] = value first, and then
set its expires
> attribute to 0.
>
Thank you very much!
--
with kind regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-6]
|
|