Jump to content


help about session control :(

  • Please log in to reply
2 replies to this topic

#1 AdrianR

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 March 2006 - 11:14 PM

Hi people.
Some gave me this script about 1 week ago.
$_SESSION['this_page_unique'] = rand(0, 10000000);
   echo "Go back.  You cannot refresh the page ";

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..

#2 toplay

  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 01 April 2006 - 02:12 AM

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]

#3 AdrianR

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 April 2006 - 07:45 AM

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..

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users