php - change random number when echo -


i have problem function in . 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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -