Home php How to use PHPSESSID to get user_id

How to use PHPSESSID to get user_id

Author

Date

Category

The user logged on on my site. He picked up in Cook phpsessid.

How, knowing this psyssid, the server can say, authorized user or not?
In which variable is this information stored?

Authorization is used by the built-in means of Yii2.

For example:

User went to the site. I registered and logged in. He was recorded in Cook PHSESSID = 6G7A6M1PRD3SDD4BATR735CDL0 . The user saw this cook and handed me.
Can I find out using this ppsessid , namely 6g7a6m1prd3sdd4batr735cdl0 find out who sits under this combination on the server?

How can this be done?

$ _ session ['6g7a6m1prd3sdd4batr735cdl0'] nothing will give
$ session = new session; $ Session- & gt; open (); $ Session ['6G7A6M1PrD3SDD4BATR735CDL0'] too.
And it is apparently logical. After all, _session belongs to a certain session, and not access to all sessions of the server.

Where should I contact to get information for this session?


Answer 1

yii :: $ app- & gt; user- & gt; isguest;

Watch the documentation for more details: http: // www. yiiframework.com/doc-2.0/yii-web-ser.html


Answer 2

you went on the right path, but almost heshed almost. You need to do this:
Yii :: $ App- & gt; Session- & gt; SETID (‘6G7A6M1PRD3SDD4BATR735CDL0’);
$ SessionData = (Array) Yii :: $ App- & gt; session;

In the SessionData variable there will be an array of data session. There is a key _ID in which the user ID is stored.
BUT! If you do it in console commands, then there will be no session component. In order to be, you need to copy the config of the user and session components.

If you want to get session data without yii in the console, then you need to do this:
session_start ();
session_id (‘6G7A6M1PRD3SDD4BATR735CDL0’);
$ sessiondata = $ _session;

And here there is again “but”. The fact is that if you try to read the session created by JII, then most likely get Bileberdo, as the session is most likely encrypted, but this is not accurate.

And even pay attention to where the session is stored. If in a non-standard storage, then the second option does not work.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions