ostinelli / misultin

Misultin (pronounced mee-sool-téen) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to use Req:cookie_get_val

comptekki opened this issue · comments

I was working with cookies in misultin. I could set the cookie and see the cookies with Req:get_cookies(), but I couldn't get Req:get_cookie_value to work. Maybe I'm doing it wrong. Say I set a cookie Req:set_cookie("my_cookie", "test"). Then when I do Req:get_cookies() I would get back [{"my_cookie","test"}], but if I did Req:get_cookie_value("my_cookie","test") I get back
undefined. What is the proper way to use Req:get_cookie_value?

setting cookies with Req:set_cookie/2 saves cookies internally but does nothing else until you actually send a response to the browser, which is the one that receives and saves the cookie.

then, when the browser sends a new request, it will pass along the saved cookie, which you can retrieve with Req:get_cookies/0.

it's basically how cookies work. this example really is self-explanatory:
https://github.com/ostinelli/misultin/blob/master/examples/misultin_cookies_example.erl

documentation is also available on the wiki page:
https://github.com/ostinelli/misultin/wiki/Exports

r.

Ah - yes - I need to go check all the examples. Sorry. I see you do
get_cookies and then use get_cookie_value on the results.

Thanks

On Wed, Nov 30, 2011 at 10:21 AM, Roberto Ostinelli
reply@reply.github.com
wrote:

setting cookies with Req:set_cookie/2 does nothing until you actually send a response to the browser, which is the one that receives and saves the cookie.

then, when the browser sends a new request, it will pass along the saved cookie, which you can retrieve with Req:get_cookies().

this example really is self-explanatory:
https://github.com/ostinelli/misultin/blob/master/examples/misultin_cookies_example.erl


Reply to this email directly or view it on GitHub:
#79 (comment)