Jump to:

23370 Posts in 18145 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » Redirect not consistent

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 930 Views
  • kmartinsson
    Avatar
    Community Member
    5 Posts

    Redirect not consistent Link to this post

    Hello,

    I've built an intranet with Silverstripe where users can login to browse permission enabled pages. When a user login he/she is supposed to get redirected to a certain page, in this case a page called News. The function I'm using is "director::redirect". This works fine the first time the user logs in but not the sebsequent times. This seems to have something to do with the pages being cached since it works if I add the "?flush=1" sequence to the URL.

    Does anyone have any idea on a solution to this issue?

    All sugestions are warmly welcome.

    Thanks,
    Kristian Martinsson
    Bluepin AB, Sweden

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Redirect not consistent Link to this post

    This works fine the first time the user logs in but not the sebsequent times

    Can you be more specific as to what happens in these times?. To redirect to the news page you should have

    return Director::redirect('news/');

  • kmartinsson
    Avatar
    Community Member
    5 Posts

    Re: Redirect not consistent Link to this post

    Hi Willr,

    Thanks for you reply.

    This is the line, located in the "init" function in LeftAndMain.php, where the CMS verifies the user's permissions:

    if(Member::CurrentUserID() && !Permission::check('Full Administrative Rights')) return Director::redirect('news/');

    It seems like the CMS remembers the last page you visited before you logged off and redirects to that page when you login the next time. I even tried to to a double redirection to first clear the cache and then redirect to the news page but with no luck.

    Br,
    Kristian

    930 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.