Advertisement
Guest User

Havenard

a guest
Sep 8th, 2009
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?
  2.  
  3.     class mySession {
  4.         var $path = 'C:\\WINDOWS\\TEMP'; // define the folder to save the sessions cache
  5.         var $id = '';
  6.         var $fd = NULL;
  7.         function __construct() {
  8.             global $_MYSESSION;
  9.             $this->id = $_COOKIE['MYSESSION'];
  10.             if (empty($this->id) || !eregi('^[a-f0-9]{32}$', $this->id)) {
  11.                 $i = 1;
  12.                 do {
  13.                     $this->id = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . microtime() . $i++);
  14.                 } while (file_exists("{$this->path}/MYSESSION{$this->id}"));
  15.                 header("Set-Cookie: MYSESSION={$this->id}");
  16.             }
  17.             $this->path = "{$this->path}/MYSESSION{$this->id}";
  18.             @ $_MYSESSION = unserialize(file_get_contents($this->path));
  19.             @ $this->fd = fopen($this->path, 'w');
  20.             while (!$this->fd) {
  21.                 sleep(10);
  22.                 @ $this->fd = fopen($this->path, 'w');
  23.             }
  24.         }
  25.         function __destruct() {
  26.             global $_MYSESSION;
  27.             fwrite($this->fd, serialize($_MYSESSION));
  28.             fclose($this->fd);
  29.         }
  30.     }
  31.     new mySession();
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement