hi i know how to store post
value into session
but how can i store session
value into post. post
into session
$_SESSION['name'] = $_POST['name'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['mno'] = $_POST['mno'];
$_SESSION['age'] = $_POST['age'];
I have an array stored in session
and i want to store
it into post
.
Can i do this? If yes then how?
I want to store all array
value in post
from session
The opposite should work without any problems.
$_POST['name'] = $_SESSION['name'];
$_POST['email'] = $_SESSION['email'];
$_POST['mno'] = $_SESSION['mno'];
$_POST['age'] = $_SESSION['age'];
If you want to hold an array you can do it like this:
$datapost = array ( 'name' => $_SESSION['name'], 'email' => $_SESSION['email']);
$_POST['info'] = $datapost;
$_POST
is not a persistent store where you can put things. The point of $_POST
is that it is populated at the start of the request , with the data that was passed to the server from the client (usually, web browser).
You can write into that array, but it won't have any special effect. It's just an array variable that's globally available in all scopes of your code. Normally, you'd just want to create a new array, and assign whatever you want in there:
$data = [];
$data['stored_foo'] = $_SESSION['foo'];
$data['submitted_foo'] = $_POST['foo'];
See also Why are Global Variables Evil?
If you want to send data back to the browser, you can:
echo
etc) header()
function) setcookie()
function)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.