Erlang/OTP Forums

Author Message

<  Erlyweb mailing list  ~  setting cookies

Guest
Posted: Tue Aug 28, 2007 4:05 am Reply with quote
Guest
Ending up in all sorts of strife trying to set cookies from within the
app_controller. I got it working as part of a request to a normal page
in a particular controller, but can't seem to it get to work from within
the main app_controller. The requirements are

1) for a request which is new and doesn't have a cookie: set cookie
2) if cookie fails to take redirect to error page. (Is there a way to
allow the session to continue after without a cookie?)
3) and continue with request.


I've tried various combinations of results to return from
app_controller:hook/1 the over all code resembles:

hook(A) ->
InitialEwc = {phased, {ewc, A},
fun(_Ewc, Data) ->
{ewc, html_container, index, [A, {data, Data}]}
end},
case yaws_api:find_cookie_val("thecookie", A) of
[] ->
%% set cookie and proceed

Key = crypto:rand_bytes(20),
NewCookie = http_base_64:encode(binary_to_list(Key)),
%% This bit is plainly wrong
{phased,
{response, [yaws_api:setcookie("thecookie", NewCookie),
{ewr, crash}]},
fun(_Ewc, Data) ->
{ewc, html_container, index, [A, {data, Data}]}
end};
_Cookie ->
%% do something with cookie
InitialEwc
end.


Any suggestions?

Jeff.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
Guest
Posted: Tue Aug 28, 2007 6:30 am Reply with quote
Guest
I just committed a fix in trunk that should make this workable. Both
the following hook/1 return values work for me (they return the same
response to the browser):

{phased, {response, [yaws_api:setcookie("foobar", "boing"),
{body, {ewc, A}}]},
fun(_, Data) ->
{html, Data}
end}

and

{response, [yaws_api:setcookie("foobar", "boing"),
{body, {ewc, A}}]}

Please check out the latest code and give it a shot.

Thanks,
Yariv

On 8/27/07, jm <jeffm@ghostgun.com> wrote:
>
> Ending up in all sorts of strife trying to set cookies from within the
> app_controller. I got it working as part of a request to a normal page
> in a particular controller, but can't seem to it get to work from within
> the main app_controller. The requirements are
>
> 1) for a request which is new and doesn't have a cookie: set cookie
> 2) if cookie fails to take redirect to error page. (Is there a way to
> allow the session to continue after without a cookie?)
> 3) and continue with request.
>
>
> I've tried various combinations of results to return from
> app_controller:hook/1 the over all code resembles:
>
> hook(A) ->
> InitialEwc = {phased, {ewc, A},
> fun(_Ewc, Data) ->
> {ewc, html_container, index, [A, {data, Data}]}
> end},
> case yaws_api:find_cookie_val("thecookie", A) of
> [] ->
> %% set cookie and proceed
>
> Key = crypto:rand_bytes(20),
> NewCookie = http_base_64:encode(binary_to_list(Key)),
> %% This bit is plainly wrong
> {phased,
> {response, [yaws_api:setcookie("thecookie", NewCookie),
> {ewr, crash}]},
> fun(_Ewc, Data) ->
> {ewc, html_container, index, [A, {data, Data}]}
> end};
> _Cookie ->
> %% do something with cookie
> InitialEwc
> end.
>
>
> Any suggestions?
>
> Jeff.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
Guest
Posted: Tue Aug 28, 2007 7:15 am Reply with quote
Guest
Yariv Sadan wrote:
> I just committed a fix in trunk that should make this workable. Both
> the following hook/1 return values work for me (they return the same
> response to the browser):
>
> {phased, {response, [yaws_api:setcookie("foobar", "boing"),
> {body, {ewc, A}}]},
> fun(_, Data) ->
> {html, Data}
> end}
>
> and
>
> {response, [yaws_api:setcookie("foobar", "boing"),
> {body, {ewc, A}}]}
>
> Please check out the latest code and give it a shot.
>

Both seem to work here as well. Had a minor glitch running the wrong
version of erlyweb. Once fixed however it worked as advertised. Much
appreciated.


Jeff.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
wailian
Posted: Tue Mar 20, 2012 2:51 am Reply with quote
Guest
One of them is the Ugg bailey button boot which has classic and uniquely designed buttons on its body to give that elegant and luxurious look. It has a fantastic look and this includes the Bailey Triplet Boot which has 3 buttons. These boots have a shaft (the upper part of the boot) which can be turned up or turned down depending upon your need. These buttons are both for style or decoration along with being functional or usable as well.

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum