views:

636

answers:

1

Is there anyway to pass a customer session to the admin side and vice versa? For example... what if I want to unify some customer and admin accounts (for some very special users =)

Usecase: Redirect a user from the customer dashboard to the admin dashboard via a link. Assume username and password are already synced.

I've been experimenting with this, by creating an admin session in the customer controller (pulling code from adminhtml/Controller/Action.php and adminhtml/controllers/IndexController.php). Then I reroute the request to the adminhtml controller.

The singleton admin/session that I create and populate with data doesn't seem to persist once the request is routed... any ideas?

A: 

I have only tried logging in a user from drupal into magento frontend. But this is how I would go about sharing a session between customer and admin.

Take a look at the following classes

/app/code/core/model/customer/model/session.php

//this retrieves the logged in customer
Mage::getSingleton('customer/session')->getUSer()

/app/code/core/model/admin/model/session.php

//this retrieves the logged in admin user
Mage::getSingleton('admin/session')->getUser()

When creating a new customer you should create an admin account for that user using the save() method in

/app/code/core/model/admin/model/user.php
Mage::getSingleton('admin/user')->save()

after that when you want to login the customer into the admin , just call

/app/code/core/model/admin/model/session.php
Mage::getSingleton('admin/user')->login()

Hopefully this will set u on the right path :)

Rick J