Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6208441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:48:35+00:00 2026-05-24T05:48:35+00:00

if $user is empty i want to redirect to authenticate page but i am

  • 0

if $user is empty i want to redirect to authenticate page but i am seeing facebook logo and require click this logo else dont go to the authenticate page.

This is my redirect code:

if($user)
{
      // code..
}
else
{
        $url = 'https://www.facebook.com/dialog/oauth?client_id=258561857493875&redirect_uri=http://apps.facebook.com/gunlukburcpaylas/&scope=email,read_stream,publish_stream,offline_access,user_birthday';
        header("location:".$url);
}

You can see from here my application.

(Sorry for my English. My first language is not English)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:48:36+00:00Added an answer on May 24, 2026 at 5:48 am

    The Facebook API does not allow you to issue Redirect headers for the Authetication page. Heres the Authentication page I use, with the pieces relevant to only my page removed. If you put this code in, it will work, as I use it in production for my facebook application. It also implements CSRF protection.
    EDIT: I removed the APP_SECRET, because I doubt you need it.

    <?php  
    $valid = false;
    
    define(APP_ID, "");
    define(CHROMED_URL, "");//this is the facebook app url in the form http://apps.facebook.com/[app name]
    
    $desired_perms = "";//place the permisions you want here
    $auth_url = "https://www.facebook.com/dialog/oauth?client_id=".APP_ID."&redirect_uri=".urlencode(CHROMED_URL)."&scope=".$desired_perms;
    
    $signed_request = $_REQUEST["signed_request"];
    
    list($encoded_sig, $payload) = explode('.', $signed_request, 2);
    
    $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
    
    if ( empty($data["user_id"])) {
        //The user is not logged in, or the user has not authorized the app
        //We start a session to maintain a marker variable for XSS attack detection
        //The auth url will log the user in AND acquire permissions if needed.
        $_SESSION['marker'] = md5(uniqid(rand(), TRUE)); //CSRF protection
        session_write_close();
        echo("<script> top.location.href='".$auth_url."&marker=".$_SESSION['marker']."'</script>");
    } else {
        if ($_SESSION['marker'] == $_GET['marker']) {
            //The user is logged in, has given the app permission, and appears to be operating under the correct session
            //marker, which protects against XSS attacks. 
    
            //lets verify the datas algorithm as a precaution
    
            if ($data["algorithm"] != "HMAC-SHA256") {
                echo("<script> top.location.href='./error.php?id=1'</script>");
                exit;
            }
            $valid = true;
    
        } else {
            //This branch means the user is logged in, but that it appears they have been subjected to
            //an XSS attack.
            echo("<script> top.location.href='./error.php?id=2'</script>");
                exit;
        }
    
    }
    ?>
    <?php if($valid): ?>
    <!-- PUT The HTML to embed your application here -->
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect to the page which has a form when user submit
I have a create.js.erb, I want make this: if the user click to create
I want to empty a table in hbase... eg: user . Is there any
User Story: Action for Facebook that has open graph object. For this I need
I have created a Page Tab Facebook App where I want to display different
I have this code, it is successfully storing the 'author_id' but I want it
With onclick=history.go(-1);return false; user can navigate to back pages. But if I want to
I have a facebook login system that seems to work fine, but I want
When a user submit forms,i'm checking empty validation and data validation. For ex:In data
I start out with an empty list and prompt the user for a phrase.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.