Jump to content

help about session control :(


AdrianR

Recommended Posts

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..
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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..
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.