If you want use twice ZendAuthenticationAuthenticationService, look in ZendAuthenticationStorageSession, you’ll see in __construct, there’s an namespace parameter, change it for “Zend_Auth_Frontend” (in front) and “Zend_Auth_Backend” for the back.
How you can perform above change please follow below steps:
For Frontend Changes Please change in two file
Step 1:
Go to ZfcUsersrcZfcUserAuthenticationAdapterAbstractAdapter.php
Search below code in AbstractAdapter.php, approx line no 23 to 25
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession(get_class($this))); |
|
}
|
and replace it with
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession('Zend_Auth_Frontend',get_class($this))); |
|
}
|
Step 2:
Go to ZfcUsersrcZfcUserAuthenticationStorageDb.php
Search below code in Db.php, approx line no 115 to 117
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession); |
|
}
|
and replace it with
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession('Zend_Auth_Frontend')); |
|
}
|
For Backend Side(Admin side) Changes Please change in two files :
Step 1:
Go to ZfcUsersrcZfcUserAuthenticationAdapterAbstractAdapter.php
Search below code in AbstractAdapter.php, approx line no 23 to 25
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession(get_class($this))); |
|
}
|
and replace it with
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession('Zend_Auth_Backend',get_class($this))); |
|
}
|
Step 2:
Go to ZfcUsersrcZfcUserAuthenticationStorageDb.php
Search below code in Db.php, approx line no 115 to 117
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession); |
|
}
|
and replace it with
if (null === $this->storage) { |
|
$this->setStorage(new StorageSession('Zend_Auth_Backend')); |
|
}
|
When your changes done after then you open frontend and backend, now you can login both side with different username and password and you see you are success to Create Different session for Backend (admin) and frontend using zfcuser in Zend framework 2.