Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

How do I store an array in URL parameters?

Olivia Rhye

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;

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy