Hi All,
I'm new to php and building my first site that will require session management. I've got a "splash page" where users will be required to select a region which I want to record into $_Session['location'].
I'd like to have the various region options be links:
<a href="/ny">New York</a>
<a href="/ma">Massachusetts</a>
etc.
When a user clicks one of these links, I want this to somehow trigger the assignment of $_Session['location']. Then i want to take users to "page1.php".
From what I've read, it is not kosher to mix client-side Javascript (e.g. onClick) with server-side php. So -- is there a solution that's reasonably elegant? Or is this simply going against the grain of how php is meant to be used?
A possible solution I've thought about is passing the location to an intermediate page as a parameter in the URL, as in <a href="/location_redirect.php?location=ny">. Then in location_redirect.php, set the session variable with $SESSION['location'] = $GET['location']. Then redirect to "page1.php" -- though I don't know the details of how to do this redirect.
Thanks for any pointers. I'd be grateful for specific ideas or general thoughts about whether this is a reasonable goal, or if there are better ways to capture a session variable from a user action.