ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Redirecting users depending on login status

August 21, 2008 2:52pm

Subscribe [2]
  • #1 / Aug 21, 2008 2:52pm

    FullCreamMilkMan

    67 posts

    The site I’m working on right now requires users to be logged in before they can access the main site. There’s a template group of login templates, the “index” of which is the home page of the site. If users are already logged in, they are redirected to the main site:

    {if logged_in}
    <meta http-equiv="refresh" content="0;url={path=home/index}"/>
    {/if}

    Similarly, if users are not logged in, they are redirected to the login pages:

    {if logged_out}
    <meta http-equiv="refresh" content="0;url={path=site_index}"/>
    {/if}

    However, with this rather ugly method there is a delay, such that the original page is displayed briefly before the redirect kicks in.

    Is there a better method I can use to achieve the same effect? Does EE have a native redirect function I can put in templates that will work more smoothly and avoid the brief display of the initial page?

  • #2 / Aug 21, 2008 3:22pm

    Lisa Wess

    20502 posts

    Why redirect? Put the code in that template, and use template Access to disallow non logged in users from viewing it.

  • #3 / Aug 21, 2008 3:35pm

    FullCreamMilkMan

    67 posts

    Sorry, put which bit of code in which template? At the moment, the {logged_in} code is present in the login pages (redirecting to the main site) and the {logged_out} code is in the main site pages (redirecting to the login pages).

    And you mean template access in the template preferences? So I’d stop Guests from seeing all the templates except the login templates and set a page to be displayed when unauthorized users try to access one of the main site templates?

    UPDATE: Actually, I’ve got this sorted, using the template access method you recommended. Thanks!

  • #4 / Aug 21, 2008 4:45pm

    Ingmar

    29245 posts

    Glad to see Lisa helped you sort it all out 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases