kvnirvana Posted November 14, 2010 Share Posted November 14, 2010 I've got this on my page index.php $rand = $_SESSION['rand']; if (empty($rand)) { srand((float)microtime()*1000003); $rand = rand(); $_SESSION['rand'] = $rand; } On all my other pages i've got this <?php unset($_SESSION['rand']) ?> The problem is that if I go to any other page than index it will unset the session 'rand'. If I then go back to index.php I get this error 'Notice: Undefined index: rand' is there a way to get around this? Quote Link to comment Share on other sites More sharing options...
marcus Posted November 14, 2010 Share Posted November 14, 2010 You're trying to give a variable the value of something nonexistent. You should try something like: $rand = (isset($_SESSION['rand'])) ? $_SESSION['rand'] : '';[code=php:0] Quote Link to comment Share on other sites More sharing options...
kvnirvana Posted November 14, 2010 Author Share Posted November 14, 2010 Thanks :=) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.