0

I am using zend session, it workssetting up on the index page and if i use jquery's and check any session data. how ever within my class the session is empty?

index.php

$usersession = new Zend_Session_Namespace();
$usersession->surveyType = array("2D","3D");
$usersession->surveyTypeSelect = 'all';

file i use for jquery

$session = new Zend_Session_Namespace();
$log = $session->log;
$cache = $session->cache;
$surveyType = $session->surveyType;
$surveyTypeSelect = $session->surveyTypeSelect;

my class

$seismicLibrary = new Spectrum_Seismic_Library();

Any function within this class returns empty values for my saved session data.

public function getAllSurveysByRegionId($regionId, $published = false) {
        //'Default'
        $session = new Zend_Session_Namespace();
        $log = $session->log;
        /*foreach ($session as $index => $value) {
            $log->debug(print_r("aNamespace->$index = '$value';\n",true));
        }*/
        $surveyType = $session->surveyType;     
        $surveyTypeSelect = $session->surveyTypeSelect;

The above function - session data is empty.

shorif2000
  • 2,582
  • 12
  • 65
  • 137

1 Answers1

0

You are setting a new session namespace in that function rather than retrieving the one you already had. You could try creating your session, then setting it to registry using Zend_Registry::set('session', $session) then when you need it anywhere else you use $session = Zend_Registry::get('session'); that way you ensure that you are using the same session namespace.

Ajaypayne
  • 517
  • 3
  • 12
  • i though when you redecalre `new Zend_Session_Namespace()` if default exists it should retrieve it ? – shorif2000 Jul 27 '15 at 13:10
  • @bonez This is directly from the documentation " if access to the session namespace is needed at a later time during the same request. For example, a developer may store the reference in a static variable, add the reference to a » registry (see Zend_Registry), or otherwise make it available to other methods that may need access to the session namespace." – Ajaypayne Jul 27 '15 at 13:30