Forum Discussion

wall_247166's avatar
wall_247166
Icon for Nimbostratus rankNimbostratus
Feb 16, 2016

Comparison with PHP Session Variable

Hi I have created a custom login screen and need the screen layout to be different depending on the URI. To do this I have created a PHP variable and set it to '%{session.server.landinguri}' Based on this variable I want to build the logic to display the relevant screen design. In theory this should work but the variable does not convert to a string. If I echo the variable, it outputs the correct uri but if you try to do a comparison or any string function on the variable it does not work. For example: if I have the following url: http://test.com/a $t = '%{session.server.landinguri}'; echo $t; The output is /a which is correct By this logic the following code should output /a if ($t == '/a') { echo "URI = /a"; } else { echo "error"; } But it does not output /a

 

Another example is : $t = '%{session.server.landinguri}'; $t2 = substr($t, 1); echo $t; echo $t2;

 

This should output : /a a

 

but it outputs : /a {session.server.landinguri}

 

I have searched the forums and found a similar post. The solution was to use javascript and not PHP. Unfortunately for this problem I need to use PHP and not Javascript. If you have any suggestions on how to handle the URI or to make use of session variables to build the logic it would be appreciated.

 

Thanks

 

1 Reply

  • From my experience trying to do similar things, this is what I understand the process to be.

     

    1. PHP code executes and renders the page
    2. F5 overwrites the session variables after PHP code has executed.

    You can check out this question too for a little more information.

     

    Unfortunately, the only way I've found is to handle anything like this through Javascript on the client side, though that doesn't give you the flexibility you're looking for (as you mentioned).

     

    Another option you could consider use an empty event in the VPE and based on that session variable pick from different logon pages. It's not ideal since you'd need to customize both of them individually, but it might accomplish your goal.