Page 1 of 1

Stop people view page more then once?

Posted: Sun Sep 14, 2003 11:26 pm
by Mr. Tech
Hi!

How do i stop people from viewing the SAME page at the SAME time? For example:

1. They go to http://www.mydomain.com/once.php

2. It would open and show all the info of the page.

3. If they open up another browser window and go to the same page (http://www.mydomain.com/once.php), it will write in the browser window "You can only view this page once at a time".

How could i do this?

Thanks,

Ben

Posted: Sun Sep 14, 2003 11:31 pm
by McGruff
Would need some kind of user registration/login/authentication system in order to identify users making a second call for the page.

Posted: Mon Sep 15, 2003 1:42 am
by Mr. Tech
Any idea where I can get one?

Maybe I can log their IP into a database.. but some IPs are the same...

Cookies could work but it might interfere with it...

Any ideas?

Thanks..

Posted: Mon Sep 15, 2003 3:56 am
by igoy
you can try using session cookies.. offcourse it also depend on user brwoser setting. also you can try using no-cache meta tag, and logging a IP.. well not exactly IP. what you can do it.. using the IP and some random generated string, create an unique string.

Let's say user's IP is 200.35.2.110, then we use that IP and add some random generated string, it will be something like "200352110xpbr99ie6".. I hope you get what I mean...

Posted: Mon Sep 15, 2003 4:07 am
by Mr. Tech
How will it remember the generated string?

JavaScript may have to be the way to go... I can use php to hide it :D

Posted: Mon Sep 15, 2003 5:01 am
by JAM
Take the idea of a Online Visitor Counter (you know, "There are now 14 people browsing this site"). There are many snippets of those out there that might be of use to you in this matter.

Slightly take the ideas from one of those, rewrite it some.

Posted: Mon Sep 15, 2003 6:42 am
by igoy
Simple... what i meant by using the Ip+string is instead of logging the IP to database use this string instead.. this solves problem of similar IP's or people who are on dynamic IPs... also you can use cookie to mark the computer... let's say session cookie is good to use since most of the browsers doesn't block it..(unless user have made such setting) but session cookie can be used in conjuction with IP+string logging or as failsafe option...

Posted: Mon Sep 15, 2003 10:24 am
by Sinnix
I think this link might help you out some. It's an article about manually expiring web pages in php: http://www.phpbuilder.com/columns/clark20030702.php3

Posted: Mon Sep 15, 2003 2:53 pm
by m3rajk
ok.
here''s one for you ( a hypothetical)
hat happens if i view it
something happens to crash my computer
5 min later (i'm on a lan so i have a static ip) i get back up and try ti view
it already started to load
how does it know i don't already have it open?

anything you do here is flawed. some pteople don't like looking at things in frames. but if you set it up to stop that you kill legitimate reasons to bring it back up as well.

Posted: Mon Sep 15, 2003 2:59 pm
by SantaGhost
i dont think its possible with php, you can put a time of for example 5mn where the ip in question cant view the page after the first view, i think you best bet on this is javascript.

maybe something with the onUnload proprety of the body tag, that the page wont be viewable for the person until onUnload has been triggered

onLoad->block ip
onUnload->release ip

Posted: Mon Sep 15, 2003 3:08 pm
by JAM
SantaGhost wrote:i dont think its possible with php, you can put a time of for example 5mn where the ip in question cant view the page after the first view, i think you best bet on this is javascript.

maybe something with the onUnload proprety of the body tag, that the page wont be viewable for the person until onUnload has been triggered

onLoad->block ip
onUnload->release ip
Why not use header()?
If the blocked ip (or whatever being used to determine the visitor status) just header() him/her to somewhere else...
m3rajk wrote:but if you set it up to stop that you kill legitimate reasons to bring it back up as well.
Very true, something worth thinking of. I have had my inet-connection break while i clicked a link on this forum. It got registered as "read" in my cookies, but I never saw the page (not until my connection went back up that is).

I can only think of one good purpose, and that is if you are displaying sensitive data (ie. "Your password is...") or something similiar.

Mr. Tech, could you explain more about the usage of this?

Posted: Mon Sep 15, 2003 3:29 pm
by SantaGhost
yes offcourse header("Location:") can be used to redirect to another page, i was thinking in someting of the following:

Code: Select all

<?php
if(status==unblock){
unblock(ip);
$unblock = "onLoad="window.close()"";
}else{
    $blockstatus
    if(blocked){
        header(location)
     }
     block(ip);
}
?>
<html>
<body<? echo $unblock ?> onUnload="top.location.href=?status=unblock&ip=ip">

</body>
</html>

Posted: Mon Sep 15, 2003 5:26 pm
by Mr. Tech
Hi guys!

Does session_start(); only last for how long you are in the browser window? Once you close it it doesn't exist anymore?

My main problem is this window I am trying to proctect from being viewed twice is a surfing window. You get points for viewing websites and after a certain amount of time the page refreshs with a new page to browse through (Uses frames...)

That stuffs up using cookies I think because if the page is refreshed it will say it can't be viewed...

Any ideas?