How do some sites detect your presence on VKontakte?

Especially often this can be seen when leaving comments. Fumbling let’s say on the article, some thread, and down there is your ava from VK. I need something similar. In general, the idea is this – I give the dude a link to my script. He follows it, and the script writes the VKontakte id in the logs, or maybe the name of the one who followed it. How to do this in PHP and how realistic it is. My level in PHP coding is beginner. Tell me which way to dig.

Answer 1, authority 100%

VKontakte authorization can only occur from the VKontakte page. And the definition probably occurs through various oauth requests. See vk api.

Answer 2, authority 100%

Look towards VK widgets. Is that what you meant?

Answer 3

Can I ask the browser for cookies from VK?

of course you can’t

The idea is a failure, of course, if there are no vulnerabilities like xss in VK itself.