473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Capturing $_REQUEST and reusing it later

I'm working on an authentication system in which it's possible that a user
might be requested to log-in as a result of submitting a form if the
inactivity timeout is exceeded. In order that they don't lose the
information in the form I would like to capture this information ($_RESULT),
serialise it and store it in their session. After they've successfully
logged in I would like to retrieve this information and put it back in
$_RESULT so the user can carry on with what they were doing. Is $_RESULT
meant to be writable in this wayand is there any reason why this isn't a
good idea?

Thanks,
Geoff
Jul 17 '05 #1
4 5379
Geoff Soper wrote:
I'm working on an authentication system in which it's possible that a user might be requested to log-in as a result of submitting a form if the
inactivity timeout is exceeded. In order that they don't lose the
information in the form I would like to capture this information ($_RESULT), serialise it and store it in their session. After they've successfully logged in I would like to retrieve this information and put it back in $_RESULT so the user can carry on with what they were doing. Is $_RESULT meant to be writable in this wayand is there any reason why this isn't a good idea?


$_REQUEST is writable, but not "carryable" as session ($_SESSION).

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #2
Geoff Soper wrote:
I'm working on an authentication system in which it's possible that a user
might be requested to log-in as a result of submitting a form if the
inactivity timeout is exceeded. In order that they don't lose the
information in the form I would like to capture this information ($_RESULT),
serialise it and store it in their session. After they've successfully
logged in I would like to retrieve this information and put it back in
$_RESULT so the user can carry on with what they were doing. Is $_RESULT
meant to be writable in this wayand is there any reason why this isn't a
good idea?


I assume by $_RESULT you mean $_REQUEST?

To store it:

foreach ($_REQUEST as $key=>$value) {
$_SESSION['REQUEST'][$key] = $value;
}

This will simply store all the $_REQUEST variables in the session as the
array $_SESSION['REQUEST']

Then to get it back:

foreach ($_SESSION['REQUEST'] as $key=>$value) {
$_REQUEST[$key] = $value;
}

Or, if they fail the login, destroy the array:
unset($_SESSION['REQUEST']);

If you don't want to store all the $_REQUEST vars but only some of them
you can just use a switch-statement before storing them.

foreach ($_REQUEST as $key=>$value) {
switch ($key) {
case "var_to_keep":
case "another_var_to_keep":
case "yet_another_var_to_keep":
$_SESSION['REQUEST'][$key] = $value;
break;
default:
break;
}
}

Just make sure you call session_start(); on the pages where you want to
use this, or the $_SESSION variables won't be carried over.

Hope that helps :)
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #3
To store it:

foreach ($_REQUEST as $key=>$value) {
$_SESSION['REQUEST'][$key] = $value;
}


Why not simply $_SESSION['REQUEST'] = $_REQUEST;?
--
* html {redirect-to: url(http://browsehappy.pl);}
Jul 17 '05 #4
porneL wrote:
To store it:

foreach ($_REQUEST as $key=>$value) {
$_SESSION['REQUEST'][$key] = $value;
}

Why not simply $_SESSION['REQUEST'] = $_REQUEST;?


Why not indeed? :)

I put the switch-statement in that loop when I started writing the post,
and decided to put it up as an alternative afterwards instead, and left
the loop as it was.
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: melty | last post by:
This line of code make an "Undefined index" error on my PC, however it is okay on my friend's PC. Anyone has this experience? $somevar = $_REQUEST;
7
by: JDS | last post by:
Hi, all. I'd like to do the following, preferably *without* resorting to JavaScript: I have a long, dynamically-generated form questionnaire. Not all of the form fields are dynamically...
2
by: Geoff Winkless | last post by:
Hi My knowledge of php is regrettably poor but I need to call a third-party php script from within a bash cgi script (don't ask why, it's a long story). Now normally (with eg perl-cgi) to do...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
6
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely...
2
by: senfo | last post by:
Hello all, To help alleviate human error, I'm developing an application that uses a barcode reader to fill in a value in a TextBox control. The barcode reader is connected to the PC through the...
11
by: jmark | last post by:
I have seen some code like $value = strval($REQUEST); I would like to know what is the use of strval here since $_REQUEST values are strings?
4
by: Fred!head | last post by:
Hi, Probably this is a newbie question so I appreciate you bearing with me. I've got an application where users can create forms with name= values they define. I'd like to write a script that...
6
by: sathyashrayan | last post by:
Dear Group, Please look at the following demo link. http://www.itsravi.com/demo/new_pms/admin/addproject.php
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.