Skip to content

Instantly share code, notes, and snippets.

@jmarrama
Created February 11, 2014 22:25
Show Gist options
  • Select an option

  • Save jmarrama/8945530 to your computer and use it in GitHub Desktop.

Select an option

Save jmarrama/8945530 to your computer and use it in GitHub Desktop.
<?php
ob_start();
/*
* Prototype : string session_id([string $id])
* Description : Get and/or set the current session id
* Source code : ext/session/session.c
*/
echo "*** Testing session_id() : variation ***\n";
$directory = dirname(__FILE__);
$filename = ($directory."/entropy.txt");
file_put_contents($filename, "Hello World!");
ini_set("session.hash_function", 0);
var_dump(session_start());
var_dump(session_id());
var_dump(session_destroy());
// if these 2 lines are moved above the 3 calls to session methods
// above, then the session module works fine without my bugfix because
// these ini settings are never set
ini_set("session.entropy_file", $filename);
ini_set("session.entropy_length", filesize($filename));
ini_set("session.hash_function", 1);
var_dump(session_start());
var_dump(session_id());
var_dump(session_destroy());
var_dump(unlink($filename));
echo "Done";
ob_end_flush();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment