P粉3189281592023-08-22 16:43:11
Yes, you can put an array into the session, for example:
$_SESSION['name_here'] = $your_array;
Now you can use $_SESSION['name_here']
on any page, but before using any session function, make sure to add the session_start()
line to your code, So your code should look like:
session_start(); $_SESSION['name_here'] = $your_array;
Possible examples:
session_start(); $_SESSION['name_here'] = $_POST;
Now you can get the field value on any page like this:
echo $_SESSION['name_here']['field_name'];
As for the second part of your question, unless you allocate different array data, the session variables will remain there:
$_SESSION['name_here'] = $your_array;
The session lifetime is set in the php.ini file.
For more information please click here
P粉1667793632023-08-22 00:57:00
Yes, PHP supports arrays as session variables. Please refer to this page for examples.
As for your second question: Once a session variable is set, it will remain the same unless you change it or unset
it. So if the third page doesn't change the session variable, it will remain the same as it was before the second page changed it.