This topic is locked

Redirect after successful login

4/7/2019 2:06:18 PM
PHPRunner General questions
J
jianwong author

Hello,
I want to redirect user, based on GroupID, to a specific page after login.
I apply the following event code on After successful login, however, it only re direct for default user group. Admin user can't be re directed but to menu page. Can anyone please share what have I missed? Thank you.

=========

if ($_SESSION["GroupID"]="default"){

header("Location: default_pg_default_view.php?editid1=1");

exit();

}
if ($_SESSION["GroupID"]="admin"){

header("Location: newsmain_list.php");

exit();

}

T
Tempus_Erus 4/7/2019



Hello,
I want to redirect user, based on GroupID, to a specific page after login.
I apply the following event code on After successful login, however, it only re direct for default user group. Admin user can't be re directed but to menu page. Can anyone please share what have I missed? Thank you.

=========

if ($_SESSION["GroupID"]="default"){

header("Location: default_pg_default_view.php?editid1=1");

exit();

}
if ($_SESSION["GroupID"]="admin"){

header("Location: newsmain_list.php");

exit();
Have a look at : https://xlinesoft.com/tiki/Built-in+session+variables
Also should the = not be ==
}

=========

admin 4/8/2019

This is incorrect:

$_SESSION["GroupID"]="default"


This is correct:

$_SESSION["GroupID"]=="default"
J
jianwong author 4/8/2019





Hi
Thank you for responding and sharing the link.
Both my events are working, meaning each will re direct based on GroupID to the specified page after user login.
However, the problem is only the first event, when user of Default GroupID login, it will re direct. Admin user login won't redirect.

But, if I remove the first event. Then the second event will work for Admin group login.
Any clues how to have both event to re direct based on GroupID? Thanks.

J
jianwong author 4/8/2019



This is incorrect:

$_SESSION["GroupID"]="default"


This is correct:

$_SESSION["GroupID"]=="default"



Thanks for the pointer, Sergey.
In my case, only single "=" works.

$_SESSION["GroupID"]="default"


As mentioned in previous posting, following the re direct event for Default group, I have another re direct event for Admin group. But it not re directing after Admin login.
Any clues or directions? Thanks.

admin 4/8/2019

I already pointed to what is wrong. I don't know what else can be added here. You are using an assignment operator instead of comparison operator. This is wrong and won't work.