N
N
Newfag19942020-05-13 08:39:56
PHP
Newfag1994, 2020-05-13 08:39:56

How to calculate the user's port on the site?

I am writing my website. In the logs of user actions, you need to store a pair of IP + port. I know how to get the user's IP. And how to get its port?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-05-13
@Newfag1994

For http port 80, for https 443. The user has no port, your server has a port.
And to get on which port it connects, use

$port = $_SERVER['REMOTE_PORT']; // типа юзер порт
$serverPort = $_SERVER['SERVER_PORT']; // 80/443

R
Rsa97, 2020-05-13
@Rsa97

Getting a port makes no sense. Since requests from the user's browser to your site can go in parallel, the browser simply uses a new port for each TCP connection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question