| @@ -9,9 +9,9 @@ | ||
| 9 | 9 | * @since 2.9 |
| 10 | 10 | */ |
| 11 | 11 | class PLL_Cookie { |
| 12 | 12 | /** |
| 13 | - * Parses the cookie parameters | |
| 13 | + * Parses the cookie parameters. | |
| 14 | 14 | * |
| 15 | 15 | * @since 2.9 |
| 16 | 16 | * |
| 17 | 17 | * @param array $args {@see PLL_Cookie::set()} |
| @@ -18,19 +18,21 @@ | ||
| 18 | 18 | * @return array |
| 19 | 19 | */ |
| 20 | 20 | protected static function parse_args( $args ) { |
| 21 | 21 | /** |
| 22 | - * Filter the Polylang cookie duration | |
| 23 | - * /!\ this filter may be fired *before* the theme is loaded | |
| 22 | + * Filters the Polylang cookie duration. | |
| 24 | 23 | * |
| 24 | + * If a cookie duration of 0 is specified, a session cookie will be set. | |
| 25 | + * /!\ This filter may be fired *before* the theme is loaded. | |
| 26 | + * | |
| 25 | 27 | * @since 1.8 |
| 26 | 28 | * |
| 27 | - * @param int $duration cookie duration in seconds | |
| 29 | + * @param int $duration Cookie duration in seconds. | |
| 28 | 30 | */ |
| 29 | 31 | $expiration = apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS ); |
| 30 | 32 | |
| 31 | 33 | $defaults = array( |
| 32 | - 'expires' => time() + $expiration, | |
| 34 | + 'expires' => $expiration > 0 ? time() + $expiration : 0, | |
| 33 | 35 | 'path' => COOKIEPATH, |
| 34 | 36 | 'domain' => COOKIE_DOMAIN, // Cookie domain must be set to false for localhost ( default value for COOKIE_DOMAIN ) thanks to Stephen Harris. |
| 35 | 37 | 'secure' => is_ssl(), |
| 36 | 38 | 'httponly' => false, |
| @@ -54,8 +56,9 @@ | ||
| 54 | 56 | * @type bool $secure Should the cookie be sent only over https? |
| 55 | 57 | * @type bool $httponly Should the cookie accessed only over http protocol? Defaults to false. |
| 56 | 58 | * @type string $samesite Either 'Strict', 'Lax' or 'None', defaults to 'Lax'. |
| 57 | 59 | * } |
| 60 | + * @return void | |
| 58 | 61 | */ |
| 59 | 62 | public static function set( $lang, $args = array() ) { |
| 60 | 63 | $args = self::parse_args( $args ); |
| 61 | 64 | |