Search This Blog

Friday, March 17, 2017

Adding $_POST array to existing $_SESSION array - PHP Resolved

This one was tricky for me.
Scenario
1. Already Have a Set of $_SESSION array

$_SESSION["val1"] => 101
$_SESSION["val2"] => 102
$_SESSION["val3"] => 103
$_SESSION["val4"] => 104


2. on FORM post creates set of $_POST array
This set of $_POST needs to be appended to existing $_SESSION sets

$_POST["val1"] => 201
$_POST["val2"] => 202
$_POST["val3"] => 203
$_POST["val4"] => 204

Simple

$_SESSION += $_POST

IT WORKS LIKE CHARMING!!!

No comments:

Post a Comment

content-wide advt