J
J
jjjjdi2021-02-27 21:05:26
PHP
jjjjdi, 2021-02-27 21:05:26

Authentication check via COOKIE?

Hello. There is a registration/authorization form for the Database, and since I am a beginner programmer, I do not yet fully know how to work with Cookies, I wrote the forms. They create cookies in the browser for this website. But, how to check these cookies so that without authorization, the user could not climb other tabs?
Examples:
Authorization - ../admin/index.php/
The file that needs to be checked for cookies - ../admin/page/add.php
It needs to be done so that when an unauthorized user goes to ../admin/page/add.php threw on the form of authorization, and passed the authorized person. Help me please

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Northern Lights, 2021-02-27
@php666

Hint:
https://www.php.net/manual/ru/function.setcookie.php
https://www.php.net/manual/ru/function.empty.php
https://www.php.net/ manual/en/function.header.php -> you need to send
the Location header

E
Evgeny Matveev, 2021-02-28
@ematveev

It is necessary to use not cookies, but sessions . Cookies are sent from the browser, so they can be easily forged by a hacker who will get full access to the admin panel in a couple of minutes, and session variables are stored on the server where the hacker does not have access.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question