0

I have this html code where i want to assign a custom value to href based on the user being authenticated in a session so when the session expires href value will change. I have the following html code:

 <a  href="<?php echo $value?>"  >Home</a>

and the zf2 code that is dealing with the change is in the controller and is as follows:

      if ($auth->hasIdentity()) { 
         $value='about'; 
       } 
      else{
        $value='';
        }
       return $value;

it successfully puts the href to 'about' but does not change it back to empty once the user session has been expired. I am not sure why is it not recognizing the else statement.

snab
  • 65
  • 4
  • 14
  • Without exactly knowing how you have set up the session, we cant help you in this. Right now from you code, all I can say is that once the 'if' condition returns true it just returns the "about" to render it to the view and it stops there. Thats why it would be good to know your session setup, after how many seconds the session gets expired, any code regarding that would help us to guide you – 125369 Aug 14 '13 at 09:55
  • as of now I have set it up so that after 100secs the session expires. And i have a check in bootstrap that redirects to the login page once the session is expired. In my code once the session is expired and i click on home again, it opens the page in the target div of 'about' but i want it to take me to login page rather than it opening in the same div. I hope that helps – snab Aug 14 '13 at 09:58
  • Well seems fine from what you have described, but with less code it is difficult to find out where the problem. May be check this [link](http://stackoverflow.com/questions/14032226/sessions-in-zf2) for some more info about zend session – 125369 Aug 14 '13 at 10:10
  • the problem is not in zend session. the problem is the value of href does not change.I dont know why it does not change. For e.g when the page is loaded after the session is expired, the value should change but it remains the same. – snab Aug 14 '13 at 10:20

0 Answers0