Ok, so I'm using sessions to track data on a new project. I've used sessions extensively in the past and never had any trouble. Now here's what's happening. I set variables using:
$_SESSION['key']='blah blah blah';

If I print_r($_SESSION) at the end of the page they are there, then in subsequent page requests they are gone. The session array exists, but does not contain all of the data that I set. It's like they are not getting really registered with the session. Has anyone run into anything like this before? Any thoughts or solutions?

Before anyone asks, yes session_start(); is called at the top of the page.

Thanks.

    Are you doing any kind of redirects (e.g. a [man]header/man redirect)? If so, try adding a [man]session_write_close/man call before the redirects.

    If not, can you perhaps post the contents of 1 script that contains all of the data, and the subsequent script that can't find all of the data?

      I've isolated the problem to the smarty class...
      If I comment out :
      // Smarty config
      //require('/usr/local/lib/php/Smarty/Smarty.class.php');
      //$smarty = new Smarty();
      //
      //$smarty->template_dir = '/var/www/vhosts/cartourz.com/smarty/templates';
      //$smarty->compile_dir = '/var/www/vhosts/cartourz.com/smarty/templates_c';
      //$smarty->cache_dir = '/var/www/vhosts/cartourz.com/smarty/cache';
      //$smarty->config_dir = '/var/www/vhosts/cartourz.com/smarty/configs';
      //$smarty->left_delimiter='%{';
      //$smarty->right_delimiter='}%';

      in an included conf file the sessions work properly. If they are not commented out, then they fail. Any idea if smarty messes with sessions? I've used smarty with sessions before without trouble.

        Found the problem. Interestingly enough if you try to assign the $SESSION array to a smarty var
        $smarty->assign('somevar', $
        SESSION);

        It clears the $_SESSION array. Why, I don't have a clue, but it's reproduceable. Not that you'd need to given that session data is available to templates already, but I was testing some things... Odd

          Oh, and just as another factor of wierdness, the $SESSION array is destroyed BEFORE the smarty assign line.
          So
          print_r($
          SESSION);
          $smarty->assign('somevar', $_SESSION);

          Will still return an empty array, unless the $smarty->assign line is commented out.

            Write a Reply...