
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
49 lines
1.5 KiB
Plaintext
49 lines
1.5 KiB
Plaintext
A cookie's domain specifies which websites should be able to read it. Left blank, browsers are supposed to only send the cookie to sites that exactly match the sending domain. For example, if a cookie was set by _lovely.dream.com_, it should only be readable by that domain, and not by _nightmare.com_ or even _strange.dream.com_. If you want to allow sub-domain access for a cookie, you can specify it by adding a dot in front of the cookie's domain, like so: _.dream.com_. But cookie domains should always use at least two levels.
|
|
|
|
|
|
Cookie domains can be set either programmatically or via configuration. This rule raises an issue when any cookie domain is set with a single level, as in _.com_.
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
== Sensitive Code Example
|
|
|
|
[source,php]
|
|
----
|
|
setcookie("TestCookie", $value, time()+3600, "/~path/", ".com", 1); // Noncompliant
|
|
session_set_cookie_params(3600, "/~path/", ".com"); // Noncompliant
|
|
|
|
// inside php.ini
|
|
session.cookie_domain=".com"; // Noncompliant
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
[source,php]
|
|
----
|
|
setcookie("TestCookie", $value, time()+3600, "/~path/", ".myDomain.com", 1);
|
|
session_set_cookie_params(3600, "/~path/", ".myDomain.com");
|
|
|
|
// inside php.ini
|
|
session.cookie_domain=".myDomain.com";
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|