[phplib] problems with the session variables From: cain (wolfram <email protected>)
Date: 09/25/99

Hi List,

another dummy question ... i am too stupid 4 that
i was no working on that for at least 24 hours - i got closer but i still have no solution
i stripped down my script to the basic things and still ....

i am trying to save a session variable named "lang",
i modified the class ct_sql to use encoding = "slashes" so i can see what is being written in the DB (encoding=base64 is unreadable) and it is all right
to see if the value of the session variable is changing i am simply increasing it, as the standard example does. and in the DB it gets updated as expected (column val=netracer:$this->in = ''; $this->pt = array(); $this->pt['lang'] = '1'; $GLOBALS['lang'] = '8';) , but my final HTML page still shows me the old value, i was trying to print $lang and $GLOBALS["lang"] but only sometimes (but rarely, and i dont know when and why) it show me the right value on the reload of the page

so i thought may be my html-page gets reloaded from the cache, but the expiration date is set to some day in 1997
just another strange thing.....
what i found strange, is that in the PHP-manual, in the chapter "setcookie()" it says: "Cookies must be sent before any other headers are sent (this is a restriction of cookies, not PHP). "
but why does the "session.inc" work if the order is not maintained as described in the manual - see the following extract of session.inc

  function start($sid = "") {
    $this->set_container();
    $this->set_tokenname();
    $this->release_token($sid);
    $this->put_headers(); // sends the headers
    $this->get_id($sid); // sets the cookie !!! after the header !!!
    $this->thaw();
    $this->gc();
  }

---------------------------------------------------------------------------------
My code
---------------------------------------------------------------------------------
<?
  include("../config.php3"); // this includes all this stuff like prepend, local.inc, etc...

  page_open(array("sess" => "Example_Session"));
  $sess->register("lang");
?>
<html>
<body>
     
<?php
  print("lang = ".++$lang." <br>");
?>
            
</body>
</html>

<?php
  page_close()
?>
---------------------------------------------------------------------------------
my config
---------------------------------------------------------------------------------
class DB_Example extends DB_Sql
{
  var $Host = $GLOBALS["DB_HOST"];
  var $Database = $GLOBALS["DB_NAME"];
  var $User = $GLOBALS["DB_USER"];
  var $Password = $GLOBALS["DB_PASSWORD"];
}

class Example_CT_Sql extends CT_Sql
{
  var $database_class = "DB_Example"; ## Which database to connect...
  var $database_table = "active_sessions"; ## and find our session data in this table.
}

class Example_Session extends Session {
  var $classname = "Example_Session";
  var $cookiename = "netracer"; ## defaults to classname
  var $magic = "some"; ## ID seed
  var $mode = "cookie"; ## We propagate session IDs with cookies
  var $lifetime = 1; ## 0 = do session cookies, else minutes
  var $that_class = "Example_CT_Sql"; ## name of data storage container
  var $gc_probability = 5;
  var $allowcache = 0; ## to be sure its not set to be public, or something
}

I hope someone can help me, because this is urgent, as usual

Thanks in advance

Wolfram