rdvn55 Posted December 15, 2023 Share Posted December 15, 2023 I ve problem with sessions. Index.php <?php session_start(); $abc=rand(10000,99999); $_SESSION["abc"]=$abc; echo $_SESSION["abc"]; ?> Page.php <?php session_start(); echo $_SESSION["abc"]; ?> I always ve different number in page.php . Whats the problem. Please help me Quote Link to comment https://forums.phpfreaks.com/topic/317541-help-session-problem/ Share on other sites More sharing options...
Barand Posted December 15, 2023 Share Posted December 15, 2023 Are you sure you don't revisit index.php between runs of page.php? Might be safer if you only set the value if is not already set if (!isset($_SESSION['abc']) { $_SESSION['abc'] = rand(10000, 99999); } Quote Link to comment https://forums.phpfreaks.com/topic/317541-help-session-problem/#findComment-1613568 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.