Page 1 of 1
Passing errors via sessions ??
Posted: Mon Sep 10, 2007 1:48 am
by PHPycho
Hello forums !!
As we know information can be passed through pages using Query strings, forms, cookies, sessions.
I would like to know how sessions can be used effectively to pass errors between different pages ?
Thanks in advance to all of you.
Posted: Mon Sep 10, 2007 9:33 pm
by Christopher
Page 1:
Code: Select all
session_start();
$_SESSION['error'] = '42';
Page 2:
Code: Select all
session_start();
echo 'Error: ' . $_SESSION['error'];
Posted: Mon Sep 10, 2007 10:47 pm
by s.dot
Seems odd to pass errors to another page.. wouldn't you want to show the error on the page it was on?
I guess this could be useful if you're using the post-redirect-get pattern, except it'd be post-redirect-session.
Posted: Tue Sep 11, 2007 12:36 am
by jmut
scottayy wrote:Seems odd to pass errors to another page.. wouldn't you want to show the error on the page it was on?
I guess this could be useful if you're using the post-redirect-get pattern, except it'd be post-redirect-session.
I think its kind of handy. Zend Framework is having such helper...called flashMessenger. yes it is post-redirect-get pattern.
And on second get message is not there anymore. Haven't look at implementation of flashMessenger.
Posted: Tue Sep 11, 2007 1:45 am
by n00b Saibot
This is definitely handy. I have been using Sessions as an easy & straight-forward way of persisting errors & notices and combined with error handlers are effective and very easily manageable solution to error reporting.
Posted: Wed Sep 12, 2007 12:12 am
by PHPycho
can anybody provide me the good link for starting post-redirect-get pattern
thanks
Posted: Wed Sep 12, 2007 12:35 am
by jmut
search google.
check Zend Framework implementation