views:

77

answers:

2

I'm working on a solution that has two applications

1) Wordpress based CRM (frontend) 2) Symfony based b2c application

Symfony application is created and working fine. When we login to symfony based application, the top menu changes with respect to person logs in. e.g. sign-in changes sign-out etc.

The thing is we need to have this same menu on the Wordpress based CRM, which should also be updated when someone logs in to symfony based application.

Let me know if you any experience or suggestion.

A: 

Wordpress gives you control over cookie verification via the function wp_validate_auth_cookie. Fortunately, this function is "pluggable", so you can rewrite it.

Make sure wordpress can see symfony's cookies (they must be in the same domain), and then have the function do something like:

session_name('symfony');

session_start();

This will give you access to symfony's $_SESSION.

The user_id is, by default, $_SESSION['symfony/user/sfUser/attributes']['sfGuardSecurityUser']['user_id']

If you're using sfGuard or sfDoctrineGuard.

This function is expected to return a wordpress user id, but the possibilities from this point and on are multiple (there are plenty of other functions that are "pluggable".

blockhead
Thanks blockhead, this was exactly the thing required.session_name('symfony');session_start();print_r($_SESSION);
Sadi
A: 

I had a similar problem a few months ago. The post is here. It says Symfony 1.2, but I'm using 1.4 now and it works fine.

The instructions in the top answer involve creating a separate controller for wordpress, which lets wordpress run inside Symfony. Then you can create a wordpress template with your menu above the wordpress output. It also lets you access the Symfony context inside wordpress, so you can overwrite the wordpress authentication functions to use Symfony's authentication.

lyoshenka