Search

Index

Revindex Storefront

How to cleanup on logout

Last updated on 2021-09-13 2 mins. to read

Revindex Storefront can automatically clear the cart when a registered user logs out from your site. This security measure prevents other users sharing the same computer from viewing the cart items of another user. This feature is controlled by the Session logout feature under Configuration > Cart settings.

If you want to perform additional clean up tasks after a user logs out, you can do so using a special page that will be redirected after logout by following the steps below:

  1. Give your page a name e.g. "Logout".
  2. Uncheck the Include in Menu checkbox.
  3. Set the page permission to allow only "Unauthenticated Users".
  4. Click Update to save.
  5. On the newly created page, add the Razor Host module to the page.
  6. On the action menu, click Edit script.
  7. Click Add new script file.
  8. Choose "CSHTML (C#)" file type.
  9. Give it a file name (e.g. "Logout.cshtml")
  10. Click Add new script.
  11. Select the script you created. It may have an underscore prefix to the name.
  12. Replace the Script Source with this code where 0 is your portal ID:

    @{
      // Perform your steps here such as expiring cookie, closing session, clear cache, etc.
      Session.Abandon();
      Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
      Response.Cookies.Add(new HttpCookie("rvdsfcart|0", "") { Expires =  DateTime.Now.AddDays(-1d) });

      // Uncomment the line below if you want to redirect to your home page.
      // Warning: Once you uncomment it, you won't be able to access this page
      // anymore since it will redirect immediately.
      // You will have to go to your local folder to edit this script
      // under DesktopModules\RazorModules\RazorHost\Scripts\<file>.cshtml.
      // Response.Redirect("~/", false);
    }
     
  13. Check on the Is Active checkbox.
  14. Click Save Script and Return.
  15. Go to your Settings > Site Settings from the persona bar.
  16. Under the User Accounts Settings tab, change the Redirect After Logout dropdown to your newly created page.
  17. Click Update.

Comments


Powered by Revindex Wiki