AdrianR Posted March 31, 2006 Share Posted March 31, 2006 Hi people.Some gave me this script about 1 week ago.[code]session_start();if(empty($_SESSION['this_page_unique'])){$_SESSION['this_page_unique'] = rand(0, 10000000);}else{ echo "Go back. You cannot refresh the page ";}[/code]It works perfect,after I enter the link I can't refresh it but just 1 hudge problem:Let`s say the link is on a page and someone clicks the link and it openes in a new browser window,even if that person clicks the link 100 times and it openes 100 new pages it says "Go back. You cannot refresh the page ".The only time the page really runs is the first time although the page loades 100 times in a new window:(.I want it just not to refresh...I hope I was clear enough,if not please let me know.Regards and thank you for your time.. Quote Link to comment Share on other sites More sharing options...
toplay Posted April 1, 2006 Share Posted April 1, 2006 There's a bug. Change this: rand(0, 10000000) to this: rand(1, 10000000).Look up empty() and you'll notice that zero is considered empty.Once fixed, it shouldn't matter if it's opened in another window. It should only run once. If you're still experiencing that it's running more than once, then the session is not being saved. In that case it could be lots of things wrong, so read my session troubleshooting guide.Info on empty():[a href=\"http://us2.php.net/manual/en/function.empty.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.empty.php[/a]Look for my session troubleshooting post at this FAQ page:[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=31047\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=31047[/a] Quote Link to comment Share on other sites More sharing options...
AdrianR Posted April 1, 2006 Author Share Posted April 1, 2006 ok I have read your troubleshooting guide about session control still it seems good to me that script.I changed the '0' to '1' but still same problem.I think I understood from your guyde that it matters if I am running the session script from a page that already has another session script(PHPbb) ? Please someone give me more information about what to do.Or someone help me by givind another script that dosen't allow refresh but works on a new page.thank you.. 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.