Guest User

Untitled

a guest
Jun 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. # my session is not working properly.
  2. # The routine(s) show no errors, but doing print_r($session) shows no object for my session either.
  3.  
  4. ## in my application.ini [text]
  5. ;session configuration
  6. sessions.name = Logins
  7. sessions.use_only_cookies = on
  8. sessions.cookie_lifetime = 36000 ;set to the number of seconds the session should stay valid for
  9. sessions.gc_maxlifetime = 36000 ;set to the number of seconds the session should stay valid for
  10.  
  11. ## in my bootstrap class [php]
  12. protected function _initConfigs()
  13. {
  14. $this->bootstrap('db');
  15. Zend_Registry::set("db", $this->getResource('db'));
  16.  
  17. $config = new Zend_Config_Ini(APPLICATION_PATH. '/configs/application.ini', APPLICATION_ENV);
  18. Zend_Registry::set("config", $config);
  19.  
  20. Zend_Session::setOptions($config->sessions->toArray());
  21. $sesion = new Zend_Session_Namespace('Logins');
  22. Zend_Registry::set("session", $session);
  23. }
  24.  
  25. ## in one of my login controller [php]
  26. //user credentials are good
  27. $session = Zend_Registry::get("session");
  28. $session->userid = $user;
  29.  
  30. ## in my view [php]
  31. $session = Zend_Registry::get("session");
  32. if (!empty($session->userid))
  33. echo "You are logged in as ". $session->userid;
  34. else
  35. echo "You are not logged in";
Add Comment
Please, Sign In to add comment