I want to authenticate chat user in my php app (through websockets). Now I am sending with chat message all cookies from domain. One of these cookies is session id. Is there any option to do something like this:
session_id($cookies['PHPSESSID']);
session_start();
echo $_SESSION['user']['username'];
Or maybe is there any other method to authenticate user ?
Yes, you can do that, with one small adjustment:
Be careful, though. Since you're using the same cookie as PHP ifself, this value is auto-generated unless of course you use
session_id($_COOKIE['PHPSESSID']);
before-hand. You'll need to make sure that an automatic session id is generated the first time the user visits your site.