Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class mySession {
- var $path = 'C:\\WINDOWS\\TEMP'; // define the folder to save the sessions cache
- var $id = '';
- var $fd = NULL;
- function __construct($id = '') {
- global $_MYSESSION;
- $this->id = $_COOKIE['MYSESSION'];
- if (empty($this->id) || !eregi('^[a-f0-9]{32}$', $this->id) || ($this->id != md5($id))) {
- if (empty($id)) {
- $i = 1;
- do {
- $this->id = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . microtime() . $i++);
- } while (file_exists("{$this->path}/MYSESSION{$this->id}"));
- }
- else {
- $this->id = md5($id);
- }
- header("Set-Cookie: MYSESSION={$this->id}");
- }
- $this->path = "{$this->path}/MYSESSION{$this->id}";
- @ $_MYSESSION = unserialize(file_get_contents($this->path));
- @ $this->fd = fopen($this->path, 'w');
- while (!$this->fd) {
- sleep(10);
- @ $this->fd = fopen($this->path, 'w');
- }
- }
- function __destruct() {
- global $_MYSESSION;
- fwrite($this->fd, serialize($_MYSESSION));
- fclose($this->fd);
- }
- }
- new mySession();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement