Using Mojolicious::Sessions for Non-Session Cookies

21 views
Skip to first unread message

Viktor Nacht

unread,
Feb 1, 2019, 6:04:14 PM2/1/19
to Mojolicious
I really love the "it just works" interface of Mojo's session cookie, and I was disappointed that I can't use that same kind of approach to other cookies. I wrote a helper to de/serialize my non-session cookies automatically, but that's still a step away from the amazing awesomeness of sessions. Is there a way I haven't thought of yet to use a Mojolicious::Sessions object for a non-session cookie that won't interfere with the normal sessions' expiration and values, etc? 

Stefan Adams

unread,
Feb 4, 2019, 3:11:04 PM2/4/19
to mojolicious
Build a MyCookie module that works like Mojolicious::Sessions, and a helper "mycookie" that does what "session" does, but using MyCookie.

Here's my prototype attempt at it.  I think it should be crafted as a plugin and of course you'll want to modify the logic so that it behaves as you intend.  But the prototype, at least, demonstrates how it could be done completely independently from Mojo's session cookie.

On Fri, Feb 1, 2019 at 5:04 PM Viktor Nacht <viktor...@gmail.com> wrote:
I really love the "it just works" interface of Mojo's session cookie, and I was disappointed that I can't use that same kind of approach to other cookies. I wrote a helper to de/serialize my non-session cookies automatically, but that's still a step away from the amazing awesomeness of sessions. Is there a way I haven't thought of yet to use a Mojolicious::Sessions object for a non-session cookie that won't interfere with the normal sessions' expiration and values, etc? 

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Viktor Nacht

unread,
Feb 7, 2019, 1:15:37 AM2/7/19
to mojol...@googlegroups.com
Thank you, Stefan. That was really helpful and educational seeing the interplay between the module, helpers and hooks. I’m looking at it trying to wrap my head around an idea for a “Mojo::MagicCookie” that would allow you to deploy multiple session-like cookies without duplicating the all of the components. Not sure I can pull it off,  but this is a great example, thank you.

V

You received this message because you are subscribed to a topic in the Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mojolicious/bNZfaboWF6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mojolicious...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages