Skip to content

HTTP Cookie utility for the elli Erlang web server

License

Notifications You must be signed in to change notification settings

elli-lib/elli_cookie

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elli_cookie

Build Status Hex Badge

A library application for reading, setting, and otherwise managing cookies in Elli.

Usage

See the large test set in elli_cookie_test for more thorough usage examples.

Basic Cookie Management and Cookie Option Settings

In an Elli callback module:

handle(Req, _Config) ->
  Cookies = elli_cookie:parse(Req),

  %% retrieve a cookie value ...
  _PublicKey = elli_cookie:get(<<"key">>, Cookies),
  %% ... and do something with it

  %% create new cookie for domain www.example.com that expires in two weeks
  FizzCookie = elli_cookie:new(<<"fizz">>, <<"buzz">>,
                               [elli_cookie:domain(<<"www.example.com">>),
                                elli_cookie:expires({2, weeks})]),

  %% delete key cookie
  DeleteKeyCookie = elli_cookie:delete(<<"key">>),

  %% return response with cookies
  {ok, [DeleteKeyCookie, FizzCookie], <<"key deleted; fizz set">>}.

About

HTTP Cookie utility for the elli Erlang web server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 100.0%