• Hi,

    I need to ensure that a particular page of my website can only be viewed when called from another page.

    I have a quiz (using a WP plugin) that ends with either a success or a failure page, depending on the user’s answers to the quiz questions. The success page takes the user to the next stage of the competition. It is essential that the user can only get to that page by answering the quiz questions correctly and can only get to that page once – i.e. I don’t want the user to be able to make a note of the success page’s URL and access it directly.

    I suspect I need to make use of some sort of variable that is set prior to the call to the success-page and validated by the success-page template.

    What would be the best practice for this? Should I set a system variable? global variable? some other technique?

    Would be very grateful for any advice.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    You can use PHP Session for that by creating session variables on the quiz page then validate them on the success page. If a user directly accesses the success page, there will be no session variables created and you can write code to check that.

    Here is more info about the PHP Session: https://www.w3schools.com/php/php_sessions.asp

    Hope this helps. ??

    Thread Starter kahoferj

    (@kahoferj)

    Hi,

    Many thanks – that’s really helpful.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to ensure that a page can only be viewed when called from another page’ is closed to new replies.