I have more values (over 20) from $_POST like this...
$name = $_POST['name'];
$username = $_POST['username'];
$city = $_POST['city'];
$mobile = $_POST['mobile'];
$address = $_POST['address'];
NOTE : I have prevented there values from SQL injection.
My question is can I know is there a way to store all these POST values in SESSION at once? Instead of this method..
$_SESSION['name'] = $name;
etc
any answers will be highly appreciated. Thank you.
Session storage can also accommodate a huge amount of data. Most browsers, including Chrome and Firefox, can store about 10 MBs of data in session storage.
A session is a global variable stored on the server. Each session is assigned a unique id which is used to retrieve stored values. Whenever a session is created, a cookie containing the unique session id is stored on the user's computer and returned with every request to the server.
Yes, You can save the class objects/instance in session and access at other pages.
You can add one array to another.$_POST
and $_SESSION
are just arrays.
Note that the keys in the second array take priority in case of duplicates.
$_SESSION += $_POST;
However, I don't see this ending well, since the client side can inject anything he wants to the session, E.G. hijacking your users session id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With