How to set a cookie in a tiled response, and then read it from the request. I tried different methods, but none of them set a cookie on the response object.
tried these methods
$self->res->cookies({name => 'foo', value => 'bar'}); $self->res->headers->set_cookie('foo=bar'); $self->res->headers->cookie('foo=bar');
plz help !!
thanks.
You can use quick access methods directly from the controller:
# Set $self->cookie(foo => 'bar'); # Get $self->cookie('foo');
http://mojolicio.us/perldoc/Mojolicious/Controller#cookie
However, if your intention is to simply save the value and receive it on subsequent requests, there is no need to set cookies directly. Moholytic sessions use signed cookies by default, will handle the complexity of cookies, and will verify that the client has not changed values.
# Set $self->session(foo => 'bar'); # Get $self->session('foo');
http://mojolicio.us/perldoc/Mojolicious/Controller#session
If sessions are the best solution for you, be sure to set the privacy of your application. Also check out: http://mojocasts.com/e4#Session
Source: https://habr.com/ru/post/910208/More articles:PHP 5.4 Interpreter for Eclipse PDT - phpDoes Mac OS X have a Lisp environment built into Emacs? - lispdistance_of_time_in_words and then delete the word "about" - ruby-on-railsRspec 2 - the class name inside the tag - ruby-on-railsHow to make qtip tooltip with cursor - jqueryUsing a CDI Injection in a Servlet - servletsFlip Android canvas vertically - androidGithub error for synchronizing with mac - synchronizationUse hash tags with Facebook share? - javascriptPass Complex JSON Object for MVC 3 action - jsonAll Articles