| 1 |
NAME |
| 2 |
Catalyst::Plugin::Session::State::Cookie - Maintain session IDs using |
| 3 |
cookies. |
| 4 |
|
| 5 |
SYNOPSIS |
| 6 |
use Catalyst qw/Session Session::State::Cookie Session::Store::Foo/; |
| 7 |
|
| 8 |
DESCRIPTION |
| 9 |
In order for Catalyst::Plugin::Session to work the session ID needs to |
| 10 |
be stored on the client, and the session data needs to be stored on the |
| 11 |
server. |
| 12 |
|
| 13 |
This plugin stores the session ID on the client using the cookie |
| 14 |
mechanism. |
| 15 |
|
| 16 |
METHODS |
| 17 |
make_session_cookie |
| 18 |
Returns a hash reference with the default values for new cookies. |
| 19 |
|
| 20 |
update_session_cookie $hash_ref |
| 21 |
Sets the cookie based on "cookie_name" in the response object. |
| 22 |
|
| 23 |
calc_expiry |
| 24 |
calculate_session_cookie_expires |
| 25 |
cookie_is_rejecting |
| 26 |
delete_session_id |
| 27 |
extend_session_id |
| 28 |
get_session_cookie |
| 29 |
get_session_id |
| 30 |
set_session_id |
| 31 |
|
| 32 |
EXTENDED METHODS |
| 33 |
prepare_cookies |
| 34 |
Will restore if an appropriate cookie is found. |
| 35 |
|
| 36 |
finalize_cookies |
| 37 |
Will set a cookie called "session" if it doesn't exist or if its |
| 38 |
value is not the current session id. |
| 39 |
|
| 40 |
setup_session |
| 41 |
Will set the "cookie_name" parameter to its default value if it |
| 42 |
isn't set. |
| 43 |
|
| 44 |
CONFIGURATION |
| 45 |
cookie_name |
| 46 |
The name of the cookie to store (defaults to |
| 47 |
"Catalyst::Utils::apprefix($c) . '_session'"). |
| 48 |
|
| 49 |
cookie_domain |
| 50 |
The name of the domain to store in the cookie (defaults to current |
| 51 |
host) |
| 52 |
|
| 53 |
cookie_expires |
| 54 |
Number of seconds from now you want to elapse before cookie will |
| 55 |
expire. Set to 0 to create a session cookie, ie one which will die |
| 56 |
when the user's browser is shut down. |
| 57 |
|
| 58 |
cookie_secure |
| 59 |
If this attribute set to 0 the cookie will not have the secure flag. |
| 60 |
|
| 61 |
If this attribute set to 1 (or true for backward compatibility) - |
| 62 |
the cookie sent by the server to the client will get the secure flag |
| 63 |
that tells the browser to send this cookie back to the server only |
| 64 |
via HTTPS. |
| 65 |
|
| 66 |
If this attribute set to 2 then the cookie will get the secure flag |
| 67 |
only if the request that caused cookie generation was sent over |
| 68 |
https (this option is not good if you are mixing https and http in |
| 69 |
your application). |
| 70 |
|
| 71 |
Default value is 0. |
| 72 |
|
| 73 |
cookie_httponly |
| 74 |
If this attribute set to 0, the cookie will not have HTTPOnly flag. |
| 75 |
|
| 76 |
If this attribute set to 1, the cookie will got HTTPOnly flag that |
| 77 |
should prevent client side Javascript accessing the cookie value - |
| 78 |
this makes some sort of session hijacking attacks significantly |
| 79 |
harder. Unfortunately not all browsers support this flag (MSIE 6 |
| 80 |
SP1+, Firefox 3.0.0.6+, Opera 9.5+); if a browser is not aware of |
| 81 |
HTTPOnly the flag will be ignored. |
| 82 |
|
| 83 |
Default value is 1. |
| 84 |
|
| 85 |
Note1: Many people are confused by the name "HTTPOnly" - it does not |
| 86 |
mean that this cookie works only over HTTP and not over HTTPS. |
| 87 |
|
| 88 |
Note2: This parameter requires Catalyst::Runtime 5.80005 otherwise |
| 89 |
is skipped. |
| 90 |
|
| 91 |
cookie_samesite |
| 92 |
This attribute configures the value of the SameSite |
| 93 |
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cooki |
| 94 |
e/SameSite> flag. |
| 95 |
|
| 96 |
If set to None, the cookie will be sent when making cross origin |
| 97 |
requests, including following links from other origins. This |
| 98 |
requires the "cookie_secure" flag to be set. |
| 99 |
|
| 100 |
If set to Lax, the cookie will not be included when embedded in or |
| 101 |
fetched from other origins, but will be included when following |
| 102 |
cross origin links. |
| 103 |
|
| 104 |
If set to Strict, the cookie will not be included for any cross |
| 105 |
origin requests, including links from different origins. |
| 106 |
|
| 107 |
Default value is "Lax". This is the default modern browsers use. |
| 108 |
|
| 109 |
Note: This parameter requires Catalyst::Runtime 5.90125 otherwise is |
| 110 |
skipped. |
| 111 |
|
| 112 |
cookie_path |
| 113 |
The path of the request url where cookie should be baked. |
| 114 |
|
| 115 |
For example, you could stick this in MyApp.pm: |
| 116 |
|
| 117 |
__PACKAGE__->config( 'Plugin::Session' => { |
| 118 |
cookie_domain => '.mydomain.com', |
| 119 |
}); |
| 120 |
|
| 121 |
CAVEATS |
| 122 |
Sessions have to be created before the first write to be saved. For |
| 123 |
example: |
| 124 |
|
| 125 |
sub action : Local { |
| 126 |
my ( $self, $c ) = @_; |
| 127 |
$c->res->write("foo"); |
| 128 |
$c->session( ... ); |
| 129 |
... |
| 130 |
} |
| 131 |
|
| 132 |
Will cause a session ID to not be set, because by the time a session is |
| 133 |
actually created the headers have already been sent to the client. |
| 134 |
|
| 135 |
SEE ALSO |
| 136 |
Catalyst, Catalyst::Plugin::Session. |
| 137 |
|
| 138 |
AUTHORS |
| 139 |
Yuval Kogman <[email protected]> |
| 140 |
|
| 141 |
CONTRIBUTORS |
| 142 |
This module is derived from Catalyst::Plugin::Session::FastMmap code, |
| 143 |
and has been heavily modified since. |
| 144 |
|
| 145 |
Andrew Ford |
| 146 |
|
| 147 |
Andy Grundman |
| 148 |
|
| 149 |
Christian Hansen |
| 150 |
|
| 151 |
Marcus Ramberg |
| 152 |
|
| 153 |
Jonathan Rockway <[email protected]> |
| 154 |
|
| 155 |
Sebastian Riedel |
| 156 |
|
| 157 |
Florian Ragwitz |
| 158 |
|
| 159 |
COPYRIGHT |
| 160 |
Copyright (c) 2005 - 2009 the Catalyst::Plugin::Session::State::Cookie |
| 161 |
"AUTHORS" and "CONTRIBUTORS" as listed above. |
| 162 |
|
| 163 |
LICENSE |
| 164 |
This program is free software, you can redistribute it and/or modify it |
| 165 |
under the same terms as Perl itself. |
| 166 |
|