Show_if logged_in issue


(Steve Brown) #1

Hi All,

 

This little bit of code in my design isnt working as expected:

 

<MySource_AREA id_name="logon_desc" design_area="show_if"> 

  <MySource_SET name="condition" value="logged_in" /> 
  <MySource_THEN>You are logged in as: xxx <a href="?SQ_ACTION=logout">Log out</a></MySource_THEN>
  <MySource_ELSE>You are not logged in. <a href="%asset_url%/_login">Login</a></MySource_ELSE>
</MySource_AREA>
 
If I click the login link (in blue) it brings up a login panel which I fill in and then it reloads the page (as expected).  However, it doesnt show the "You are logged in..." text, it still shows the "You are not logged in..." text.  
 
If I then refresh the page (using F5) it corrects itself and shows the "You are logged in.." text as would be expected.
 
Why does it require a refresh to work?
 
Thanks,
 
Steve.
Version: 5.1.6.1
Browser: Chrome and Firefox
 
 

(Tim Davison) #2

I reckon it's probably caching the 'built' page, either in the matrix cache or possibly locally.  I've run into the same issues using show_if areas like this.  I found I was better off keeping all login/logout functions in the login form design area.  Login form design area seems to be have optimized caching (or whatever) for this exact type of situation.  The logic is almost identical to the show_if design area.

 

If you're clever, you can even build the login form into the page directly rather than spitting them out to a new one (on the other hand, I don't know what this does to page load/cache performance).

 

https://manuals.matrix.squizsuite.net/designs/chapters/login-form-design-area