- July 2010 (1)
- June 2010 (4)
- May 2010 (3)
- April 2010 (6)
- March 2010 (6)
- February 2010 (8)
- January 2010 (13)
- December 2009 (4)
- October 2009 (2)
- September 2009 (1)
Zend Framework Application Progress
Today I learned from Zend Framework.
Redirecting visitors to their intended URI after login
LoginForm.php
... // Grabs the requested URI from the server and stores it in a hidden field $this->addElement('hidden', 'referrer', array('value' => $_SERVER['REQUEST_URI'])); ...
Then after you complete authentication, send them to the referring URI
if($form->getValue('referrer')) $this->_redirect($form->getValue('referrer')); $this->_redirect('index/index');
Credits:
http://stackoverflow.com/questions/1249274/redirect-to-previous-page-in-...
Throwing an error message
This one is easy. You want to throw an error message with some meaning.
throw new Zend_Exception('This is the error message');
Saving data in Zend_Session
You want to save some data in a session variable so you can access it other places in application. So in the Bootstrap.php file you would place
Zend_Session::start();
To set the variable you would use
$ns = new Zend_Session_Namespace('hello'); $ns->domain = "Hello World";
By using the namespace "hello" or whatever you want, then you can keep your variables separate from another part of the applicate that just might happen to name it's variable "domain" as well.
To retrieve this fun filled variable.
$ns = new Zend_Session_Namespace('hello'); print $ns->domain;
Comments
Post new comment