I've tried to leave ot the statement but it doesn't make any
difference...:teeth:
kim
umpirsky wrote:
>
> Hi,
>
> correct me if I'm wrong, but I think its not necesarry to start session,
> it's done in ZS when needed.
>
> Regards,
> Saša Stamenković.
>
>
> KimG wrote:
>>
>> Hi,
>>
>> i'm trying to use zend session in an application.
>>
>> In my boostrap i have the following:
>>
>> Bootstrap.php:
>>
>> Zend_Session::start();
>>
>> and
>>
>> protected function _initOutlet(){
>> $out = new Zend_Session_Namespace('outlet');
>> if (!isset($out->outlet)) {
>> echo 'outlet initialised...';
>> $file = '/var/www/pimp/application/configs/outlet-config.xml';
>> $config = new Outlet_Configuration_Xml();
>> $config->load($file);
>> Outlet::init($config->toArray());
>> $outlet = Outlet::getInstance();
>> $outlet->createProxies();
>> $out->outlet = $outlet;
>> }
>>
>>
>> the _initOutlet initilises the outlet ORM and writes the information to
>> the session.
>>
>> My first question is, if starting the session in the boootstrap file is
>> the correct place?
>>
>> second, it seems like the session gets flushed with every request from
>> the client. i write a test statement to see if outlet is initialised. it
>> should show only the first time but it shows up repeatedly. I don't
>> understand why.
>>
>> I know the information is present in the session, because i'm using it
>> during user login like this:
>>
>> the user is presented with a login screen and when clicking 'login' i do
>> the following in a autorise helper:
>>
>> $userDao = new UserDAO();
>> $username = $value;
>> $password = $context['password'];
>> $user = $userDao->validateUser($username, $password);
>>
>> if($user == null){
>> $this->_error(self::NOT_AUTHORISED);
>> return false;
>> }
>> // write user info to session
>> $sesuser = new Zend_Session_Namespace('user');
>> $sesuser->user = $user;
>> return true;
>>
>> my UserDAO class does this:
>>
>> $outletNS = new Zend_Session_Namespace('outlet');
>> $outlet = $outletNS->outlet;
>> $pwhash = self::computePasswordHash($password);
>> $usersfound = $outlet->select('User', 'WHERE username = ? and
>> password = ?', array($username, $pwhash));
>> if($usersfound == null){
>> return null;
>> }
>> $user = $usersfound[0];
>> return $user;
>>
>>
>> and it works.
>>
>> in other words it can retrive the outlet info from the session and query
>> the database.
>>
>> when the user is authenticated the user information is written to the
>> session in my validate function and he is forwarded to an welcome page
>> using $this->_forward.
>>
>> in this page i can retrive the user info all right like this:
>>
>> $user = new Zend_Session_Namespace('user');
>> $this->view->user = $user->user->username;
>>
>> and use the information in my view.
>>
>> when the user navigates to the main page ('located' in another
>> controller) i need the user information again but this time there is a
>> request involved which seems to clear the session.
>>
>> because in my controller action i do this:
>>
>> $this->view->user = $user->user->username;
>>
>> I receive the following note when running this code:
>>
>> Notice: Trying to get property of non-object in......
>>
>> which basically mean that the object is no longer present in the session.
>>
>> can someone please explain to me what i'm doing wrong?
>>
>> is it my php setup that is wrong?
>> session.auto_start off
>> session.save_handler files
>> session.use_cookies on.
>>
>> if other relevant info is needed please let me know.
>>
>> thanx in advance for any help.
>>
>> kim
>>
>>
>>
>>
>>
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Session-questions-tp24199670p24199767.html
Sent from the Zend Framework mailing list archive at Nabble.com.