Authentication

Prevent Session Fixation and Reduce Session Hijacking Risk

Use secure cookies, session ID rotation, HTTPS, and reauthentication to reduce common PHP session attacks.

Use HTTPS everywhere

Session cookies should never travel over an unencrypted connection. Enable the Secure cookie attribute and redirect HTTP requests to HTTPS.

Set safe cookie attributes

Use HttpOnly and an appropriate SameSite policy. These reduce exposure but do not protect a compromised device.

Rotate session IDs

Regenerate the session ID after login and privilege changes:

session_regenerate_id(true);

Do not accept session identifiers from URL parameters.

Reauthenticate for sensitive actions

Require a recent password check or multi-factor challenge before changing email addresses, authentication factors, or other high-impact settings.

Support session revocation

Provide a way to revoke active sessions and invalidate sessions after password resets or suspected compromise. Do not rely on IP address or user-agent alone as proof of identity.