R
R
rinatoptimus2015-09-30 17:53:53
PHP
rinatoptimus, 2015-09-30 17:53:53

How to restrict access to a page by link?

The user is sent a link to a certain page, and only this user should be able to follow it and get to this page.
If the person who received this link shares it with someone and he tries to follow it, he should not get to this "secret" page.
How does is called? Access limitation? How can this be implemented?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Maxim E, 2015-09-30
@creativeworm

First option:
If the link will work one-time, then you can generate a unique code, write it in cookies or explicitly pass it in the get parameter, remove access (code / token) immediately after the page request and display an error when you request it again.
Second option:
Implement personal accounts for users and track suspicious activity/authorizations.

O
Optimus, 2015-09-30
Pyan @marrk2

Well, you can set a password, but if the user has shared a link, then he can share the password too :)

D
Dmitry, 2015-09-30
@mytmid

Step 1: Generate a link with a unique temporary key and remember the key (for example, in the database), for example: mysite.ru/catalog?token=hs84ygh3973y47t298t
Step 2: As soon as the user clicks on the link, delete the key from the database, and add an entry to the user's cookies (key or something similar) that access is allowed.
As a result, only the link can be navigated to and only by one user and only from one browser.

M
Magzhan Birgebayuly, 2015-09-30
@henhanshi

For example through:
But it's kind of hot. Better via PHP:

if( $_GET['pass'] != 'qwerty' ) header('Location: /');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question