How do I store an array in URL parameters?
December 10, 2018
Convert Array to URL parameters
This is how you can provide a link to a page with data that is already ready to go. Putting them as parameters in an array can help you load that array object again when visiting the page as a different user.
$saveurlparams = urlencode(json_encode($_SESSION['data']));
$saveurl = 'https://example.com?params=".$saveurlparams;
Bring it back now ya’ll
In the example, the data array is stored in a session variable “data”. If we visit the URL we made in step one, it should then override the array object. This loads the settings from the previous user experience, so the new user can view the site with those settings – also useful for the same user to pick up where they left off if they bookmark the link.
//load
if(isset($_GET['params'])):
$params = htmlspecialchars($_GET['params'], ENT_QUOTES, 'utf-8');
$data = json_decode(html_entity_decode($params), true);
session_start();
$_SESSION['data'] = $data;
endif;