Created
June 9, 2012 08:17
-
-
Save Checksum/2900087 to your computer and use it in GitHub Desktop.
Stronger PHP Session IDs
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 | |
// Generating stronger PHP session IDs | |
// Change from default PHPSESSID | |
ini_set('session.name','my_cookie'); | |
// Use only cookies to prevent session ID hijacking | |
ini_set('session.use_cookies', 'true'); | |
ini_set('session.use_only_cookies', 'true'); | |
// By default, ID is generated using MD5. Make it longer and more secure | |
ini_set('session.hash_function', 'sha256'); | |
// Get random bytes to increase entropy | |
ini_set('session.entropy_file', '/dev/urandom'); | |
ini_set('session.entropy_length', '32'); | |
session_start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment