On an application I have both symfony and wordpress installed. I can read the symfony session from wordpress.
My goal is to generate the WordPress menu (in header.php) by doing a request to symfony:
<?php echo file_get_contents($menu_url ); ?>
Because I need to have a WordPress header which contains informations from the symfony user (name, links, ….).
My idea would be to send to the session_id in the request so symfony directly generates the proper menu directly.
The problem is that I don’t find information on how to handle session_id sent on the url.
Thanks for your help / proposals !
I tried it a few months ago.
In php documentation:
http://php.net/manual/en/function.session-id.php
If you use session_id(Your-session-id-passed-by-url) and then with session_start you can handle the session for this id. But the problem was that I use session_autostart in my application and you can’t init session if the session is initiated yet. 🙁 It was hard problem.
My solution: If you have your symfony application and your wordpress in the same domain you can do an ajax request from wordpress to symfony (You don’t need pass session id, because the session id is the same in both applications, no?) Then you catch the content via ajax and write your header via JS.
another way: Keep all information that you need to construct your header in cookies. for example “user name”. When the user log in symfony you start that cookie and then you can use it from wordpress via JS. Change dynamically the elements of the header whit JS, reading that cookies. This is my favorite solution, and I use this now.
Well, I’m sorry. I can’t explain better because I don’t write english as well as I would like. But I think that my answer may be usefull.
Good luck.