# Session into class does not works

- Thread: https://externals.io/message/417
- Original archive: https://news-web.php.net/php.internals/417
- Started by michel 'ziobudda' morelli on 2003-03-28T13:45:33+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #417 — michel 'ziobudda' morelli — 2003-03-28T13:45:33+00:00

URL: https://externals.io/message/417#417

Class for manage a session. It works with php 4.3.x but not with PHP5
(cvs every day). 

Note the read_session() function.

bye

<?php
 `ob_start()`;
error_reporting (E_ALL);
Function zb_debug($stringa)
{
    echo "$stringa<br>";
}

class zb_session
{
    var $dbms;
    var $session_exist;
    var $session_close = false;

    function __construct()
    {
        zb_debug("Sono nel costruttore");
session_set_save_handler(array(&$this, "open_session"),
                         array(&$this, "close_session"),
                         array(&$this, "read_session"),
                         array(&$this, "write_session"),
                         array(&$this, "destroy_session"),
                         array(&$this, "gc_session")
                        );
 `session_start()`;

        //$this->OpenConnect();
    }

    function __destruct()
    {
        zb_debug("Sono nel distruttore");
        if ($this->session_close === false) `session_write_close()`;
        //$this->dbms->DisconnectSQL();

    }

   function zb_session()
   {
   $this->__construct();
   }

    function open_session()
    {
        zb_debug("Dentro open_session()");
        zb_debug("Sessione aperta");
        return true;
    }

    function close_session()
    {
        $session_close = true;
        zb_debug("Dentro close_session");
        zb_debug("Sessione chiusa");
        return true;
    }

    function read_session($sessionid)
    {
        zb_debug("Dentro read_session");
	zb_debug("This is the value of my `session_encode()`: id|i:0;");
	session_decode('id|i:0;');
	zb_debug("After session_decode: \$_SESSION:");
	var_dump($_SESSION);
	zb_debug(" ");
        return true;
    }

    function write_session($sessionid,$sess)
    {
	zb_debug("session_encode = ".session_encode());
        return true;
    }

    function destroy_session($sessionid)
    {
        zb_debug("Dentro destroy_session");
        return true;
    }

    function gc_session()
    {
        zb_debug("Dentro gc_session");
        return true;
    }

}

zb_debug("------INIZIALIZZO SESSIONE-----");
$hnd = & new zb_session;
zb_debug("------ FINE INIZIALIZZO SESSIONE-----");
zb_debug("------SESSIONE START-----");
//session_start();
zb_debug("------FINE SESSIONE START-----");
    zb_debug("------SETTO ID------");
    $_SESSION['id']++;
    zb_debug("------FINE SETTO ID------");

echo "id = ".$_SESSION['id']."<br>";
echo "_SESSION = ";
var_dump($_SESSION);
zb_debug("<br>------Chiudo la sessione------");
 `session_write_close()`;
zb_debug("------FINE Chiudo la sessione------");
echo '<a href="
'.$_SERVER['PHP_SELF'].'?"'.session_name().'='.session_id().'">Clicca
qui</a>';
 `ob_end_flush()`;
?>


-- 
michel 'ziobudda' morelli <michel@ziobudda.net
