Help! sessions problem

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
Php version: 8.2

You are generating a new $abc value on every page load with rand. By the way, PHP allows line breaks. Putting all the code on a single line just makes it harder to read and debug.

What is the purpose of doing this first of all?

Every time you go to the index page OR include the index page you should get a new random number, by your design.

Sponsor our Newsletter | Privacy Policy | Terms of Service