On my Facebook account, the app is automatically disabled when the user logs out of my web app

In my web application, a user logs in with their email id, connects a Facebook user account, a facebook post status and logs out of the website (there is a "disable" option to disconnect a Facebook account from the website) login at a time when the already connected Facebook user account should be in a connected state, that is, the user does not need to reconnect to the Facebook account.

                if ( isset( $session )) { 

                $session = new FacebookSession( $session->getToken() );
                $_SESSION['fb_token'] = $session->getToken();
                $session = new FacebookSession( $session->getToken() );
                $request = ( new FacebookRequest( $session, 'GET', '/me' ) )->execute();
                $user = $request->getGraphObject()->asArray();
                $_SESSION['fb']=$id=$user['id'];
                $_SESSION['fb_username']=$user['name'];
                $logoutURL = $helper->getLogoutUrl( $session, 'https://sharebulk.com/profile/disconnect.php' );?>       
                        <div class="col-sm-5 " >
                            <div style="  margin-left: 20%;" >
                                <img src="../images/facebook-icon.png" height="51px" width="69px">

                            </div >
                            <p>
                                <a href="<?php echo $logoutURL ;?>" class="btn btn-xlarge btn-facebook ">DisConnect  </a>
                            </p>
                        </div>
                <?php } else {
                    $loginUrl = $helper->getReRequestUrl(["public_profile", "user_managed_groups","publish_actions","email","user_posts","user_photos",
                                                "publish_pages", "manage_pages","user_birthday","user_status","read_stream"]);?>
                            <div class="col-sm-5 " >
                                    <div style="  margin-left: 20%;" >
                                        <img src="../images/facebook-icon.png" height="51px" width="69px">
                                    </div >
                                    <p>
                                        <a href="<?php echo $loginUrl ;?>" class="btn btn-xlarge btn-facebook ">Connect Facebook</a>
                                    </p>
                            </div>
            <?php }  ?>     

      

In image facebook account is connected

In logout.php: -

                <?php 
                session_start(); 
                unset( $_SESSION['uid']);
                header('Location:index');

            ?>

      

Here $ _SESSION ['uid'] is the e-mail identifier from which the user enters the login (login with e-mail).

How can I manage the Facebook session, so if the user logs out of their web app, and if the user logs in again, then the Facebook session should be there until the user deactivates the dashboard form. I am using PHP.

thank

+3


source to share


1 answer


You are looking for a Long Lived session, you can save a long lived session to your database, and when the user connects back, you can use the same long lived session to connect it back to facebook .. I hope these links help you



+1


source







All Articles