userid_expires

Sets the duration for which user ID cookies will be valid.

Syntaxuserid_expires time;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The userid_expires directive in NGINX is used to specify the expiration time for user ID cookies, which can assist in maintaining user sessions across server restarts. It accepts a single argument that represents the duration for which the cookie is active. Once this time has elapsed, the user ID cookie will become invalid, leading to the necessity for the user to re-authenticate when returning to the site. This directive impacts both session management and security, as determining a proper expiration time is critical for maintaining user session integrity while also minimizing risks of stale sessions.

The value of the userid_expires directive can be specified in various time formats such as seconds, minutes, hours, or days, and must be a positive integer followed by a valid time unit. To implement this directive, you can place it within specific contexts such as http, server, or location, allowing for tailored settings across different parts of your NGINX configuration. It's important to note that setting an overly long expiration period could compromise security as it may allow unauthorized access to sessions if a user's cookie becomes exposed.

Config Example

http {
    userid_expires 30m;
}

Ensure the time value is specified correctly; an incorrect format may lead to NGINX not accepting the directive.

Setting an excessively long expiration time can lead to security vulnerabilities if cookies are compromised.

← Back to all directives