Documentation, and more importantly, some code examples would be very useful. I would prefer this to not be in protected scripts, but in the code that goes into modern packages.
相关问题
- Plone- How can I create a control panel for a reco
- How light weighted Dexterity-base contenttype can
- zc.buildout 2.0.0 release somehow ends up breaking
- How do you scale an animated GIF image in PIL and
- How do I add keywords to SearchableText for a Dext
相关文章
- TinyMCE Toolbar Missing After Plone 4.3 Upgrade
- Invalidate/prevent memoize with plone.memoize.ram
- Extending table columns in collection view in Plon
- What's the modern way to solve Plone deadlock
- Unable to use Diazo (plone.app.theming) on Centos
- How can I remove portlets in edit mode with Plone
- Is there an easy way in Plone to get email notific
- Best way to count page view in Plone
To set cookies you use RESPONSE.setCookie.
The cookie will end up in the REQUEST in the next request.
You "delete" the cookie by using
None
as a value.**Note, though, that most of the times when people use cookies it's to store variables that have to do with sessions, and you can use self.REQUEST.SESSION for that, it's easier.
Use the
response.setCookie()
method. You can reach the response object via the request object. The latter you can reach via acquisition (self.REQUEST
), or in views by accessing the passed-in request object, usually viaself.request
:where
options
end up as extra cookie parameters. Thus, turning a cookie into a non-session cookie requires aexpires='date'
keyword, limiting the cookie to a path is apath='/somepath'
keyword to thesetCookie()
method. The usual browser cookie rules apply here.To expire a cookie already set in the browser, you could either use a
expires='date in the past'
keyword, or you could use theresponse.expireCookie()
method, which does this for you:In this case you can still include options like the
path
or other cookie flags, but the method will override themax_age
andexpires
options to ensure the cookie is deleted by the browser.Although you could use Zope's
SESSION
support, you really need to think through the scalability issues. For example, you need to think through how session data will be shared across a cluster if you use ZEO or RelStorage. It is generally preferable to avoid usingSESSION
altogether if scalability is going to be an issue.