My WebApp (using facebook login) logs me out


I use the facebook Login on my website

window.fbAsyncInit = function() { // init the FB JS SDK FB.init({ appId : 'XXX', // App ID from the App Dashboard channelUrl : 'XXX/channel.php', // Channel File for x-domain communication cookie : true, // set sessions cookies to allow your server to access the session? frictionlessRequests: true }); };

The problem is, I get logged out on my website every ~10-20min. The site it than reloading and I'm logged in again. I think the cookies gets deleted somehow.

Is there a way to make that cookie exist longer?

My login looks like that:

FB.login(function(response) {}, {scope:'publish_actions'});


This part of my script is called when a user logs in the first time:

// triggers on first login if (isset($_GET['first_login'])) { if ($me) { $facebook->setExtendedAccessToken(); $friends = $facebook->api('/me/friends'); $friends = $friends['data']; if (!empty($friends)) { // sql } $permissions = $facebook->api("/me/permissions"); if( array_key_exists('publish_actions', $permissions['data'][0]) ) { $attachment = array( 'message' => 'XXX', 'name' => 'XXX - App', 'link' => 'XXX', 'description' => 'XXX', 'picture'=> 'XXX', 'access_token' => $facebook->getAccessToken() ); $facebook->api('/'.$facebook->getUser().'/feed', 'POST', $attachment); // sql } header('Location: http:/xxx'); } }

But I get an error


Fatal error: Uncaught OAuthException: (#1) An error occured while creating the share thrown in /facebook/base_facebook.php on line 1254


Which is caused by $facebook->api('/'.$facebook->getUser().'/feed', 'POST', $attachment);

When I remove the link-attribute from my $attachment, it works. Is the link attribute forbidden or something?


You should look into extending facebook access tokens

<a href="https://developers.facebook.com/docs/howtos/login/extending-tokens/" rel="nofollow">https://developers.facebook.com/docs/howtos/login/extending-tokens/</a>

however this uses the app secret so should not be done in javascript but in a server side language as well (possibly by combining your code with the php-sdk)


  • Facebook setExtendedAccessToken() and FB.Event.subscribe('auth.login')
  • How to customize information in reporting manager
  • Can't expand nodes in TreeView (WinForms)
  • javascript created control values are not posting to server
  • A two-user tic tac toe using JSF
  • Accessing resx file from another project / assembly
  • Set up a cron every hour
  • Adding a child to Viewport3D asynchronously gives “This API was accessed with arguments from the wro
  • Android ICS x86 on VirtualBox with Internet Connection
  • React native how to get “getPackageManager()”
  • Incorrect UI update after reordering rows in UITableViewController
  • How to reload a page only once everytime it gets loaded
  • XMLHttpRequest in IE-7
  • Chrome breakpoint on radio doesn't fire
  • 'doc_del_count' bigger than 'doc_count' on CouchDB
  • How can I get the choice “H2” back in the H2 consol?
  • What causes the runtime difference in this trivial fortran code?
  • Upload file that is in the cpan database
  • Wrong labels when plotting a time series pandas dataframe with matplotlib
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • pillow imaging ImportError
  • D3 get axis values on zoom event
  • What and where is mdimport
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Xcode 4 NSLog Macro link in Xcode 3
  • Custom validator control occupying space even though display set to dynamic
  • JSON response opens as a file, but I can't access it with JavaScript
  • Django rest serializer Breaks when data exists
  • Recording logins for password protected directories
  • All Classes Conforming to Protocol Inherit Default Implementation
  • Is there any way to access browser form field suggestions from JavaScript?
  • Websockets service method fails during R startup
  • How do I rollback to a specific git commit
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Getting error when using KSoap library to consume .NET web services
  • File not found error Google Drive API
  • Qt: Run a script BEFORE make
  • apache spark aggregate function using min value
  • How to get NHibernate ISession to cache entity not retrieved by primary key