4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Forcing visitors to visit main page first
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
multiverso
Junior WebHelper
Junior WebHelper


Joined: 20 Sep 2004
Posts: 3

PostPosted: Mon Sep 20, 2004 10:04 am (13 years, 2 months ago) Reply with QuoteBack to Top

Hi!

This is my first post, so hello to all and please excuse my english.

I hope I'm posting this on the right forum Rolling Eyes

I would like to know if there is a way to do this:


    I have a link on my main page that points to the section

    I would like to force my visitors be be able to enter the section only when they click on the link located on the main page. I don't want to allow them to go directly to http://www.mydomain.com/section. If they go directly I would like to display a message (html page or an alert or something) saying that they have to enter that section of my site throught the main page, clicking on the link that points to that section. Maybe also would redirect them to my main page after several seconds.


In short what I would like is to be sure that my visitors always see my main page before going to the sections of my site, and that they reach those sections from the main page, not entering directly .

I don't have any idea how to do this. I have some knowledge of XHTML/PHP/CSS, but I guess that you have use a CGI script or maybe tweak the .htaccess file for this job...

Thanks in advance for reading this post and for any help.

________________________________
Thanks!
Multiverso
OfflineView User's ProfileFind all posts by multiversoSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Sep 20, 2004 4:06 pm (13 years, 2 months ago) Reply with QuoteBack to Top

PHP could do it by analysing the HTTP_REFERER variable, but the problem is that the HTTP_REFERER variable is sometimes blank, which would mean that some people accessing the subpages via the main page wouldn't be able to get in.

One solution, which isn't ideal but at least resolves part of the problem is to set a cookie the first time the user is redirected to the main page, and not to redirect them more than once. Still not perfect though I'm afraid Sad

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Mon Sep 20, 2004 9:48 pm (13 years, 2 months ago) Reply with QuoteBack to Top

When the main page is generated, a random number could be generated which is appended to each link in the query string. Match this number to something unique to the client (IP address combined with user agent or something), and if it's not valid don't let them see the page.

Just out of interest, why would you want to require people to visit your home page first?

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Tue Sep 21, 2004 6:11 am (13 years, 2 months ago) Reply with QuoteBack to Top

Ah, good idea Adam! Starts getting a little complicated though... Smile

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Tue Sep 21, 2004 7:09 am (13 years, 2 months ago) Reply with QuoteBack to Top

It needs to be complicated, since what multiverso is asking isn't as simple as you might think Smile

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
multiverso
Junior WebHelper
Junior WebHelper


Joined: 20 Sep 2004
Posts: 3

PostPosted: Tue Sep 21, 2004 7:54 am (13 years, 2 months ago) Reply with QuoteBack to Top

Hi, thanks Daniel & adam for your answers!

I think that maybe the easiest way to accomplish what I want is using cookies.

Daniel wrote:

One solution, which isn't ideal but at least resolves part of the problem is to set a cookie the first time the user is redirected to the main page, and not to redirect them more than once. Still not perfect though I'm afraid Sad


I would like the user to be redirected to the main page EVERY time he tries to visits the section directly. So I could be something like setting a cookie when the visitor click the link on the main page (or visit the main page) and checking this cookie when the visitor enters the section. If the cookie is present that means the visitor has seen the main page first (or clicked the link), but if the visitor tries to enter the section directly the cookie would not be present, so he will be alerted and eventually redirected to the main page. If the cookie is present (because he has clicked the link on the main page or visited it) he will be allowed to continue looking to the section, but the cookie should be deleted, because next time he visits the section he would have also to do it by clicking link/visiting the main page.

Unfortunately I don't know how to program cookies. If anyone knows how to code what I explained, I would be extremely grateful Very Happy

I hope I have explained myself (english is not my native language)

Thanks again for reding and for your help!

________________________________
Thanks!
Multiverso
OfflineView User's ProfileFind all posts by multiversoSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Tue Sep 21, 2004 8:00 am (13 years, 2 months ago) Reply with QuoteBack to Top

The PHP manual would be a good place to start: http://www.php.net/manual/en/features.cookies.php (Assuming you want to use PHP)

Edit: also, you can go here for other languages Smile

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
multiverso
Junior WebHelper
Junior WebHelper


Joined: 20 Sep 2004
Posts: 3

PostPosted: Tue Sep 21, 2004 9:47 am (13 years, 2 months ago) Reply with QuoteBack to Top

Thanks adam!

I think the best way is to to it myself, so let's study about cookies!

Thanks again to all

________________________________
Thanks!
Multiverso
OfflineView User's ProfileFind all posts by multiversoSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.065778 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme