$_SESSION variable not saving on page refresh or new page

So I have a form that allows the user to select a city. Once selected, this city is then saved to a $_SESSION variable as such : $_SESSION['city_selected'] = $_POST['location_select'];

This works fine once selected. When I var_dump($_SESSION); I see my variable perfectly on after selecting the city and the page refreshing.

Then, if I move to a different page or refresh the same page - the var_dump(); returns NULL

I can't seem to figure this out. My PHP session ID doesn't change.

I am using WAMP on a local server, and session files are saving in the \tmp folder.

Am I missing something? What the heck is happening?

Topic session localhost cookies php Wordpress

Category Web


Are you using session__start() ; at the top of that other page? You always need to retrieve session data when changing pages.

https://www.php.net/manual/en/function.session-start.php

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.