K. Kilian Lindberg
K. Kilian Lindberg

Reputation: 2976

In php saving all $_GET variables in a session variable and make them accessible trough $_GET again

I would like to save all $_GET variables in a session variable and make them accessible trough $_GET again later on.

Some pseudo code / algoritm

page1.php send form with a field as <form action="page1.php" method="get"><input type="text" value="banan" name="apa">

page2.php save all $_GET variables

page3.php Set back all get-variables as in page2.php so the first variable is accessible trough $_GET['apa']

is this possible?

Upvotes: 0

Views: 1949

Answers (2)

WWW
WWW

Reputation: 9860

Don't do this. But to save:

<?php

session_start();
$_SESSION["GET"] = $_GET;

?>

and to retrieve:

<?php

session_start();
$_GET = $_SESSION["GET"];

?>

I think the real problem here is that you have a goal you want to accomplish and you think this is the right way of achieving that goal. It's not; there is most assuredly a better way of accomplishing the end result you want. But you have to tell us what that end result is supposed to be.

Upvotes: 1

Mike Brant
Mike Brant

Reputation: 71384

It is possible, but I am not sure why one would want to do that. Why not just read the data from $_SESSION rather than $_GET so as to not confuse session data with data that is actually passed as parameter to the page you are on.

Upvotes: 1

Related Questions