• Page 1 of 1
  • 1
Forum moderator: bigblog  
How to redirecting to file catalog
Harina
Posts: 62
Reputation: 0

Message # 1 | 1:37 PM
Hello there we want a users to be taken to a file catalog home page when they log on to site regardless which page they will log on from. Is this possible? Has anyone tried it on their site and was working? Thank you!
Soldierdevil
Posts: 154
Reputation: 1

Message # 2 | 3:22 AM
Harina,

Code
<?if($USER_LOGGED_IN$)?>
<script>
window.location.href = "http://yourdomain.com/load";
</script>
<?endif?>


I am not sure if you insert it on top of site it will work but it works at home page template. You might need to insert it manual in all codes.

Systems developer
joexyz
JOE-vascript
Posts: 1770
Reputation: 78

Message # 3 | 8:54 PM
Soldierdevil, this will make all pages inaccessible for logged-in users, I'm not sure this is what OP wants. If that's the case, then your answer is good.

In all other cases, I'd suggest using cookies. The general idea is to have a cookie (let's call it "justLoggedIn") that would be checked upon by a script that will execute on every page load. If this cookie exists in the user's browser, then don't do anything. Otherwise, create the cookie and redirect the user to /load. If the user is logged out and the cookie exists, delete the cookie and redirect to whatever page (/, for example).

Harina, if this is what you have in mind, let me know and I'll try to help you write this script for your website.

Quote Soldierdevil ()
I am not sure if you insert it on top of site it will work but it works at home page template. You might need to insert it manual in all codes.

Should work in global blocks, if that's what you mean.

hey i'm joe and i do not work for the company anymore, please contact other staff or tech support
icon by ch-chau

sometimes i lurk here
Harina
Posts: 62
Reputation: 0

Message # 4 | 1:31 AM
bigblog, yes please help me with my site everywhere and i am paying. I want my site to work on some way but i cant make it work because i dont know making sites well. Please send me a contact
joexyz
JOE-vascript
Posts: 1770
Reputation: 78

Message # 5 | 11:37 PM
Harina, this should do the job:
Code
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
<script type="text/javascript">
  window.onload = function () {
  <?if($USER_LOGGED_IN$)?>
    if (!Cookies.get('uuser_logged_in')) {
      Cookies.set('uuser_logged_in', 1, { expires: 365 } );
      window.location.href = '/load';
    }
  <?else?>
    if (Cookies.get('uuser_logged_in')) {
      Cookies.remove('uuser_logged_in');
    }
  <?endif?>
  }
</script>


place this in the Bottom part of the website global template

hey i'm joe and i do not work for the company anymore, please contact other staff or tech support
icon by ch-chau

sometimes i lurk here
  • Page 1 of 1
  • 1
Search: