Login in Wordpress and use this logged user in Symfony
I have a page developed in Wordpress and to enter to this page you have to register and then login into the same.
Now I have to develop another system and I have to use the same session in my new page that was logged in Wordpress.
In the Wordpress page there is a link that brings to Symfony 2 page. Clicking in that link, the user must be the same.
I am using the same database for both applications, so the wp_users table from Wordpress is used by the new Symfony2 page.
For example the user logged in Wordpress page has to fill certain form developed in the new Symfony2 page.
I found this bundle but I don't know how to use it. It seems very useful.
My questions are:
Daniel, what you are asking for is possible but is some pretty technical stuff. Your best bet is to try and follow the instructions for the bundle you linked to get the user auth working. Baring that if you wanted to roll your own solution, assuming you are on symfony 2.8 or later you would need to implement a custom user provider and a guard.
http://symfony.com/doc/current/cookbook/security/guard-authentication.html
Basically the idea would be to read the session cookie created by wordpress, use doctrine to look up that session again in wordpress db, get the user ID associated with that. Use that User ID to load the custom user entity you created for the custom user provider.
Someone providing that solution on here likely wont happen with just how much effort would be involved.
链接地址: http://www.djcxy.com/p/63156.html