
Please see the () for an example of using secure cookies in production, but allowing for testing in development based on NODE_ENV.įorces the session to be saved back to the session store, even if the session was never modified during the request. If you have your node.js behind a proxy and are using secure: true, you need to set "trust proxy" in express. This is useful when the Express "trust proxy" setting is properly setup to simplify development vs production configuration.

Be careful when using this setting if the site is available both as HTTP and HTTPS, as once the cookie is set on HTTPS, it will no longer be visible over HTTP. The cure option can also be set to the special value auto to have this setting automatically match the determined security of the connection. If secure is set, and you access your site over HTTP, **the cookie will not be set**. However, it requires an https-enabled website, i.e., HTTPS is necessary for secure cookies. Please note that secure: true is a **recommended option**. Be careful when setting this to true, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection. By default, the Secure attribute is not set.

When truthy, the Secure attribute is set, otherwise it is not.

Specifies the boolean value for the Secure Set-Cookie attribute.
