I'm trying to get the value of an URL parameter and save it to a JS variable using PHP session.
My URL: domain.com/?id=MYID
My PHP code:
session_start();
$_SESSION['id'] = $_GET['id'];
And then I'm saving it in JS variable as:
<script type="text/javascript"> var id = '<?php echo $_SESSION['id']; ?>'; </script>
My question is, is it possible to keep the value of $_SESSION['id']
even when I visit domain.com
(without the id
parameter on 2nd visit) with the same browser?