Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 pages: config.php, login.php and facebook_login.php. I set redirect url in config.php. When users logged in via Facebook, the pages redirect to home. Because I have multiple login button into pages when users come to login.php depends on what button they click on I would like to redirect users to different pages from login.php to Facebook page. Such as to index.page, admin.page or product page, etc. How can I redirect users in the light of what I have just told?

P.S.: Array config.php or $Config['return_url']) in facebook_login.php might be a problem.

Thank you!

PHP
**config.php**

 "https://www.example.com/login",    

    "return_url" => "https://www.example.com/home",     

"facebook" => array(
        "Statu" => 1, 
        "app_id" => "",
        "app_secret" => "",     
        "default_graph_version" => "v2.5",      
     ),
)

?>
 **login.php**

facebook<a>";

?>
**facebook_login.php** back-end

get('me?fields=id,name,email';

   $accessToken);

   $UserData = $UserData->getGraphNode()->asArray();

   $data = array();

   $data['oauth'] = "facebook"

   $data['uid'] = $UserData['id'];
 
   $data['name'] = $UserData['name'];

   $_SESSION['loginer'] = array("uid" => $data['uid'], "name" => $data['name'], "oauth" => 

   $data['oauth']);
 
   unset($_SESSION['FBRLH_state']);

   header("location: ".$Config['return_url']);

   exit();

} 

?;


What I have tried:

PHP
if (!isset($_SESSION['loginer'])) {

header("location: product.php");
Posted
Updated 11-Aug-23 11:10am
v4

1 solution

As a side comment, should '"Statu" => 1' not be '"Status" => 1'?

Your problem lies in the fact that you are closing your session with:
PHP
unset($_SESSION['FBRLH_state']);

When you want to redirect, you are checking if the session is set using:
PHP
if (!isset($_SESSION['loginer'])) {

which will be false as you have closed your session, meaning the page will not re-direct. You can check it using:
PHP
if (!isset($_SESSION['loginer'])) {

header("location: product.php");
} else {
echo "I have closed the session, there are no session for me";
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900