John Davidson

Keep PHP session active after removing the URL parameter

0 comments
Message:


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?



My Answer:

Rate this post

4 of 5 based on 9885 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us