php - How to set persistent connect with Facebook -
i have, on website, login facebook (api php). when user, click on "connect facebook" (and it's ok), give him session log in him on website ... but, if user close browser, session destroy ...
so, question is, how do, persistent connection ...
here code:
if(!$member->isloggedin()){ //set facebook $fb_s = zend_registry::get('config'); $config = array( 'appid' => $fb_s->facebook->appid, 'secret' => $fb_s->facebook->secret ); $facebook = new facebook($config); $user = $facebook->getuser(); //not logged in on website, logged in on fb if($request->getcontrollername() != "login"){ =========> $user empty .... if($user){ try{ $user_profile = $facebook->api('/me'); $membres = new membre(); if(!$membre = $membres->getmemberbyfb($user_profile['id'])){ // need re logged in"; if($a = app_frontend_login::logmefb($membre) == 1){ $this->_redirect('/'); } } }catch(facebookapiexception $e){ error_log($e); $user = null; } } }
thank (in advance) ...
if want login user when php session on logged on facebook, must use javascript facebook api check user state in client side.
that's way 'remember me' option if don't want force user click in 'connect facebook' if app has been authorized.
Comments
Post a Comment