How to I restrict access to certain html files hased on where they are called from?

Discussion in 'Site & Server Administration' started by Ajeet, Nov 21, 2009.

  1. #1
    Hi,

    Say I have 4 html files:
    1.html
    2.html
    3.html

    I want to allow users to reach 2.html only if they click a link on the page 1.html If they directly write the URL into the address bar, or click a link from some other site / page, they should not be allowed to reach 2.html

    Likewise 3.html should only be accessible by clicking a link from 2.html and in no other way.

    How would I do this?

    Thanks
    Ajeet
     
    Ajeet, Nov 21, 2009 IP
  2. new

    new Peon

    Messages:
    1,433
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #2
    new, Nov 22, 2009 IP
  3. jmpf

    jmpf Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Ajeet,

    I'd recommend making a 'state machine' for this particular problem.

    Basically what happens is when the user goes to the first page you create a new entry in a 'beenthere-donethat-bought-the-t-shirt' table. So for the first page the user's info is stored as 'state=page1'. When he reaches the 2nd page he is updated to 'stage=page2' an so forth.

    I wouldn't use any sort of cookie authentication for this at all as that can usually be faked w/out signing the session to a private key of some sort -- chances are that the cookies you have on this guy don't do that right now, but who knows times are changing.

    Instead of thinking -- oh great I have to create a new user for each request just think -- I'm creating a new session for each user and it is stateful.

    It's really quite easy to implement. Let me know if you need more help or want me to expand on this.

     
    jmpf, Nov 23, 2009 IP