PluginProbe
HTTP Headers / 1.13.4
HTTP Headers v1.13.4
1.19.5 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.12.0 1.12.1 1.12.2 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.14.0 1.14.1 1.14.2 1.15.0 All 60 releases
http-headers / views / cookie-security.php

cookie-security.php in HTTP Headers 1.13.4, at views/cookie-security.php

67 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5 ?>
6 <tr>
7 <th scope="row">Cookie security
8 <p class="description"><?php _e('A secure cookie is only sent to the server with a encrypted request over the HTTPS protocol.', 'http-headers'); ?></p>
9 <p class="description"><?php _e("To prevent cross-site scripting (XSS) attacks, HttpOnly cookies are inaccessible to JavaScript's Document.cookie API; they are only sent to the server.", 'http-headers'); ?></p>
10 <p class="description"><?php _e('SameSite prevents the browser from sending this cookie along with cross-site requests. The main goal is mitigate the risk of cross-origin information leakage. It also provides some protection against cross-site request forgery attacks.', 'http-headers'); ?></p>
11 </th>
12 <td>
13 <fieldset>
14 <legend class="screen-reader-text">Cookie security</legend>
15 <?php
16 $cookie_security = get_option('hh_cookie_security', 0);
17 foreach ($bools as $k => $v)
18 {
19 ?><p><label><input type="radio" class="http-header" name="hh_cookie_security" value="<?php echo $k; ?>"<?php checked($cookie_security, $k); ?> /> <?php echo $v; ?></label></p><?php
20 }
21 ?>
22 </fieldset>
23 </td>
24 <td>
25 <?php settings_fields( 'http-headers-cose' ); ?>
26 <?php do_settings_sections( 'http-headers-cose' ); ?>
27 <?php
28 $items = array('Secure', 'HttpOnly', 'SameSite');
29 $cookie_security_value = get_option('hh_cookie_security_value');
30 foreach ($items as $item)
31 {
32 $is_disabled = $item == 'SameSite' && !is_samesite_supported();
33 $is_checked = is_array($cookie_security_value) && array_key_exists($item, $cookie_security_value);
34 if ($is_disabled) {
35 $is_checked = false;
36 }
37 ?>
38 <p>
39 <label><input type="checkbox"
40 class="http-header-value"
41 name="hh_cookie_security_value[<?php echo $item; ?>]"<?php echo $is_disabled ? ' disabled' : NULL; ?>
42 value="1"<?php echo !$is_checked ? NULL : ' checked'; ?><?php echo $cookie_security == 1 ? NULL : ' readonly'; ?>> <?php echo $item; ?><?php
43 if ($item == 'SameSite' && $is_disabled)
44 {
45 ?> <small><?php _e('(PHP 7.3+ only)', 'http-headers'); ?></small><?php
46 }
47 ?></label>
48 </p>
49 <?php
50 if ($item == 'SameSite')
51 {
52 foreach (array('None', 'Lax', 'Strict') as $s_val)
53 {
54 ?>
55 <p class="hh-csv-value<?php echo !$is_checked ? ' hh-hidden' : NULL; ?>">
56 <label><input type="radio"
57 class="http-header-value"
58 name="hh_cookie_security_value[SameSite]"
59 value="<?php echo $s_val; ?>"<?php echo !is_array($cookie_security_value) || !array_key_exists($item, $cookie_security_value) || $cookie_security_value[$item] != $s_val ? NULL : ' checked'; ?><?php echo $cookie_security == 1 ? NULL : ' readonly'; ?>> <?php echo $s_val; ?></label>
60 </p>
61 <?php
62 }
63 }
64 }
65 ?>
66 </td>
67 </tr>