2

I am running a Zend Framework application and I have to integrate a third party chat application and for that I need to have access of signed in user's ID, How can I access this id that is stored in Zend session.

Because this is not working

if (!empty($_SESSION['Zend_Auth']['storage']->user_id)) {
$userid = $_SESSION['Zend_Auth']['storage']->user_id;
}

2 Answers2

1

you can use this to get user id from storage

$userInfo = Zend_Auth::getInstance()->getStorage()->read();
echo $userInfo->user_id;
amirmohammad
  • 374
  • 3
  • 20
  • Thanks but Other application creates its own session and we can't access zend there. it will not work, either I have to include zend session or use cookies to remember user_id. – user1871962 Jan 29 '13 at 06:46
0

If you feel more comfortable using your approach ($_SESSION) you can do it like this:

if (!empty($_SESSION['Zend_Auth']['storage']['user_id'])) { // <- Changed from '->' to ['']
    $userid = $_SESSION['Zend_Auth']['storage']['user_id']; // <- same as above
}

Hope this helps :)

Stoyan Dimov
  • 5,250
  • 2
  • 28
  • 44