Problem/Motivation
We are trying to set the Drupal Session Cookie with the "Secure" Flag.
For the “SESS*” cookie, we were not able to set the "SESS*" cookie with the "Secure" flag.
We have tried from the settings.php using the following code:
ini_set('session.cookie_secure', 1);
However it did not work.
https://acquia.my.site.com/s/article/360037119453-Drupal-session-cookie-attributes
Drupal will set the Secure attribute on session cookies when the site is being accessed via https.
However, the 'Secure' flag is not set as seen in the screenshot.
Currently, we are using drupal version 9.5.9.
We are raising it as a bug as we are resolving a security finding from a pentest scan.
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot 2023-08-14 at 17.02.28.png | 307.65 KB | afiq-0922 |
Comments
Comment #2
cilefen commentedThis is not a bug but more of a setup issue on your end. In particular you probably have a forward cache or other web site setup issue such that the Drupal is unaware it is running on SSL.
Usually there is a missing header or similar. This is the code that determines if the request was SSL:
You can see that the first way is if certain headers are set from a configured trusted proxy. The second way is if the web server set the HTTPS environment variable.
Comment #4
cilefen commented