tag:blogger.com,1999:blog-6265608756663924839.post1902957591996389575..comments2017-01-26T01:29:53.039-08:00Comments on Dukes of Erl: Erlang Terms in CookiesMichael Radfordhttp://www.blogger.com/profile/16558736208373025619noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6265608756663924839.post-5531372462256410222011-12-21T10:55:40.960-08:002011-12-21T10:55:40.960-08:00Yea thx, i changed it to:
to_base64_char (63) ->...Yea thx, i changed it to:<br />to_base64_char (63) -> $+.<br />from_base64_char ($+) -> 63.<br /><br />btw... just to have it in comments for other user:<br /><br />-include_lib("eunit/include/eunit.hrl").<br /><br />base64_bijective_test() -><br /> lists:foreach(fun(X) -><br /> B = <>,<br /> B64 = to_base64(B),<br /> <> = from_base64(B64),<br /> ?assertEqual(B, B1) end,<br /> lists:seq(1,64535)).<br /><br />base64_mochicookie_test() -><br /> B64 = [ to_base64(<>) || X <- lists:seq(0,4096) ],<br /> lists:foreach(fun(X) -> mochiweb_cookies:cookie("t", X) end, B64).gebihttps://www.blogger.com/profile/02726867824497339744noreply@blogger.comtag:blogger.com,1999:blog-6265608756663924839.post-32152195686283375882011-12-21T08:48:58.243-08:002011-12-21T08:48:58.243-08:00Thanks for pointing that out gebi.
To fix this, y...Thanks for pointing that out gebi.<br /><br />To fix this, you could either change lines 41 and 50 or define your own codec via ct_expand as in the next post http://dukesoferl.blogspot.com/2009/08/metaprogramming-with-ctexpand.htmlPaul Mineirohttps://www.blogger.com/profile/05439062526157173163noreply@blogger.comtag:blogger.com,1999:blog-6265608756663924839.post-73529522763755630862011-12-20T22:22:35.200-08:002011-12-20T22:22:35.200-08:00Hi Max,
seems your code does not work with newer ...Hi Max,<br /><br />seems your code does not work with newer mochiweb as they now reject ','gebihttps://www.blogger.com/profile/02726867824497339744noreply@blogger.comtag:blogger.com,1999:blog-6265608756663924839.post-87823529322923521362010-01-25T14:55:18.160-08:002010-01-25T14:55:18.160-08:00Hey argl ...
I'm trying to understand your co...Hey argl ...<br /><br />I'm trying to understand your comment, since my solution does not use a '=' character in its codec. I use a-z, A-Z, 0-9, '.', and ','.Paul Mineirohttps://www.blogger.com/profile/05439062526157173163noreply@blogger.comtag:blogger.com,1999:blog-6265608756663924839.post-62549445039386647282010-01-25T13:44:28.154-08:002010-01-25T13:44:28.154-08:00If you really plan to use this straight as a cooki...If you really plan to use this straight as a cookie value, beware that the '=' character is interpreted as a value assignment in some browsers.<br /><br />Base64 uses the '=' character for padding, and mochiweb refuses to set that cookie (error, quoting neccesary). Solution is to use a modified base64, which uses other characters:<br /><br />...<br />to_base64_char (61) -> $_;<br />to_base64_char (62) -> $-;<br />to_base64_char (63) -> $+.<br /><br />...<br />from_base64_char ($_) -> 61;<br />from_base64_char ($-) -> 62;<br />from_base64_char ($+) -> 63.<br /><br />for more info, google for base64_urlUnknownhttps://www.blogger.com/profile/05074497551541614497noreply@blogger.comtag:blogger.com,1999:blog-6265608756663924839.post-89276795609756646192009-10-08T04:43:39.449-07:002009-10-08T04:43:39.449-07:00Oh, my god. I consider, that much better is to sto...Oh, my god. I consider, that much better is to store JSON in cookies.<br /><br />http://github.com/maxlapshin/erlyvideo/blob/master/src/rtmp_session.erl<br /><br />Look at it, I encode session to JSON, then Base64 it, than sign with SHA1 and get reliable session storage.max.lapshinhttps://www.blogger.com/profile/12637758996253923148noreply@blogger.com