vendredi 10 juillet 2015

generate random session id if random session id not same rediract to x page in php

I have a two page(page1.php and page2.php).

In page1.php

Am generate a random number, and also creating a session for random number the code is following

<?php
session_start();
$rand = (rand(1000,10000));
$_SESSION['rand'] = $rand; //random number is 7553
?>

In page2.php

in this page if random number is not same redirect to XX.php page. Or else page2.php will open.

Am trying this following code

<?php
session_start();
if(!$_SESSION['rand']) //random number 7553 is not same
{
header("Location: xx.php"); 
}
?>

If you have another idea means tell me. Thank You For Advance




Aucun commentaire:

Enregistrer un commentaire