Problem with &_SESSION When browser loads for the first time
Posted: Thu Mar 13, 2008 7:05 am
Hi there
I have an application that stores a random number in a session variable and uses this number to uniquely index a file. Later in the application this variable is then retrieved for that session in order to obtain the correct file that has been indexed and load that file into an applet. Now this process works fine in every instance except the very first time after the browser has been loaded. So for example if I opened the browser and ran it then the session variable would be returned as blank but if i went back and refreshed it and tried again then it would work fine.
Does anyone have an idea why it is not being set the first time after the browser is loaded?
I set the session var in a file using
$num = rand(0,10000);
session_start();
$_SESSION['num']=$num;
and then accesses it in a later file using
session_start();
$randnum = $_SESSION['num'];
$uploadedFile = "http://wired.st-andrews.ac.uk/~robin/ex ... andnum.jpg";
however as i said the first time it is run in a newly opened browser the applet tries to load http://wired.st-andrews.ac.uk/~robin/ex ... s/file.jpg with no index number attached???
Thanks for all your help
Robin
I have an application that stores a random number in a session variable and uses this number to uniquely index a file. Later in the application this variable is then retrieved for that session in order to obtain the correct file that has been indexed and load that file into an applet. Now this process works fine in every instance except the very first time after the browser has been loaded. So for example if I opened the browser and ran it then the session variable would be returned as blank but if i went back and refreshed it and tried again then it would work fine.
Does anyone have an idea why it is not being set the first time after the browser is loaded?
I set the session var in a file using
$num = rand(0,10000);
session_start();
$_SESSION['num']=$num;
and then accesses it in a later file using
session_start();
$randnum = $_SESSION['num'];
$uploadedFile = "http://wired.st-andrews.ac.uk/~robin/ex ... andnum.jpg";
however as i said the first time it is run in a newly opened browser the applet tries to load http://wired.st-andrews.ac.uk/~robin/ex ... s/file.jpg with no index number attached???
Thanks for all your help
Robin