Passing errors via sessions ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Passing errors via sessions ??

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Page 1:

Code: Select all

session_start();
$_SESSION['error'] = '42';
Page 2:

Code: Select all

session_start();
echo 'Error: ' . $_SESSION['error'];
(#10850)
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post 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.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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.
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post by PHPycho »

can anybody provide me the good link for starting post-redirect-get pattern
thanks
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

search google.
check Zend Framework implementation
Post Reply