Give arguments of initialize() a name or a pair of name/value. The value of cookie is omittable.
cookie = CKCookie.new( name, value )
CKRequest has some methods for getting cookies. The methods are cookie(key), cookies, cookie_value(key), cookie_values(key). You can get CKRequest objects by CKApplication#request.
Method | Description |
---|---|
cookie(key) |
Returns a CKCookie object whose key is the same as the argument. |
cookies |
Returns an array of CKCookie objects. |
cookie_value(key) |
Returns the value of CKCookie object whose key is the the same as the argument. |
cookie_values(key) |
If the argument is nil(by default, argument is nil.), this method returns an array which has all the values of cookies. Otherwise, it returns an array which has the values of cookies specified by the argument. |
CKResponse has methods for setting cookies. These methods are defined in CKMessage, the superclass of CKResponse. Use add_cookie(cookie) and remove_cookie(cookie).
cookie = CKCookie( 'name' ) application.response.add_cookie( cookie )
Send cookies with the same name to browser. If you set past expiration time for the cookie when of that, browser removes the cookie completely.
cookie = CKCookie "name" cookie.expire = Time.new - 60 response.add_cookie cookie
CKResponse#remove_cookie removes cookies in CKResponse object.
application.response.remove_cookie( 'name' )