page1:
session_start();
$_SESSION['allCaps']=array("img01.png", "img02.png"...); // 20 images
page2:
shuffle($_SESSION['allCaps']);
$_SESSION['fiveCaps'] = array_slice($_SESSION['allCaps'], 0, 5);
foreach ($_SESSION['fiveCaps'] as $key=>$val)
echo $key." ".$val; // result - five img.names - remember this
page3:
session_start();
shuffle($_SESSION['fiveCaps']);
foreach ($_SESSION['fiveCaps'] as $key=>$val)
echo $key." ".$val; // result - five img. names - remember this
I excpect the two results allways to be the same, of course except the ordering the elements (because of shuffle on page3).
But sometimes the results are the same, sometimes (after reloading page3) – are not
On page3 appear the elements which don’t exist on page2
Remove this line from page 3:
Also, be aware sometimes sessions get lost, because the web server was restarted.