php - change random number when echo -
i have problem rand function in php. set random number on $_session , in other place echo this. every time echo $_session, value on changed. code in page1:
session_start(); $_session['y'] = rand(1,100); echo $_session['y'];
and in other page2 write this:
session_start(); echo $_session['y'];
how can solve it?
note page2 appended ajax page1 when clicking on button.
it sounds including page 1 on page 2.
option 1
do not include page 1 on page 2.
option 2
check see if random number exists before setting it.
session_start(); if (! isset($_session['y'])) { $_session['y'] = rand(1,100); } echo $_session['y'];
Comments
Post a Comment