Created
November 10, 2021 18:09
-
-
Save krabello/2ec37a5349891953a1de38afa02e65eb to your computer and use it in GitHub Desktop.
Session Start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (session_status() == PHP_SESSION_NONE) { | |
// Prevents javascript XSS attacks aimed to steal the session ID | |
ini_set('session.cookie_httponly', '1'); | |
// ** PREVENTING SESSION FIXATION ** | |
// Session ID cannot be passed through URLs | |
ini_set('session.use_only_cookies', '1'); | |
// Uses a secure connection (HTTPS) if possible | |
ini_set('session.cookie_secure', '1'); | |
// SameSite attribute to cookie to help mitigate Cross-Site Request Forgery | |
ini_set('session.cookie_samesite', 'None'); | |
// session_regenerate_id(true); | |
session_start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment