class Lucky::CookieJar

Included Modules

Defined in:

lucky/cookies/cookie_jar.cr

Constant Summary

HABITAT_SETTINGS = [{decl: on_set : (HTTP::Cookie -> HTTP::Cookie) | ::Nil, example: nil, validation: nil}] of Nil
LUCKY_ENCRYPTION_PREFIX = (Base64.strict_encode("lucky")) + "--"
MAX_COOKIE_SIZE = 4096

Class Method Summary

Instance Method Summary

Class Method Detail

def self.configure(&) #

[View source]
def self.empty_jar : Lucky::CookieJar #

[View source]
def self.from_request_cookies(cookies : HTTP::Cookies) : Lucky::CookieJar #

[View source]
def self.settings #

[View source]

Instance Method Detail

def clear : Nil #

Delete all cookies.


[View source]
def clear(&block : HTTP::Cookie -> ) : Nil #

Delete cookies with a block to add specific options.

jar.clear do |cookie| cookie.path("/") .http_only(true) .secure(true) end


[View source]
def delete(key : Key) : Nil #

https://tools.ietf.org/search/rfc6265#page-8 to remove a cookie, the server returns a Set-Cookie header with an expiration date in the past. The server will be successful in removing the cookie only if the Path and the Domain attribute in the Set-Cookie header match the values used when the cookie was created.


[View source]
def delete(key : Key, &) : Nil #

Delete a specific cookie by name key. Yield that cookie to the block so you can add additional options like domain, path, etc...


[View source]
def deleted?(key : Key) : Bool #

Returns true if the cookie has been expired, and has no value. Will return false if the cookie does not exist, or is valid.


[View source]
def get(key : Key) : String #

[View source]
def get?(key : Key) : String | Nil #

[View source]
def get_raw(key : Key) : HTTP::Cookie #

[View source]
def get_raw?(key : Key) : HTTP::Cookie | Nil #

[View source]
def raw : HTTP::Cookies #

[View source]
def set(key : Key, value : String) : HTTP::Cookie #

[View source]
def set_raw(key : Key, value : String) : HTTP::Cookie #

[View source]
def settings #

[View source]
def updated : HTTP::Cookies #

[View source]