Output Prostores Account Links

In Prostores it is good practice to provide Sign In and Sign Out links for the user. When the user is signed out, they should see "Sign In", and when they user is signed in, they should see "Sign Out".

When you create your Prostore, you will want to output Sign In/Out links depending on whether the user is signed in or not. To do that, we use the $customer object, and use the function isLoggedIn()

<!-- Your Account, Login, Sign In, Register -->
<ul>
<li><ss:if test="$customer.isLoggedIn()">
<ss:link source="$storeVersion.logoff">Sign Out</ss:link>
<ss:else />
<ss:link source="$storeVersion.customerHistory">Sign In</ss:link>
</ss:if></li>
<li><ss:link source="$storeVersion.customerRegistration">Register</ss:link></li>
<li><ss:link source="$storeVersion.customerHistory">Account History</ss:link></li>
<li><ss:link source="$storeVersion.lostPassword">Lost Password</ss:link></li>
</ul>

As you can see with the above code, the Sign In/Out links are dependent on whether or not the user is signed in.

Comments

Gotcha

It is possible to that that code can display "Sign Out" even though the customer has just logged out.

This usually happens on the first page that loads when customers hit the log off button.  My guess is that the aboved code is executed first before logging of the customer.

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.

More information about formatting options