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 7441665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:03:10+00:00 2026-05-29T11:03:10+00:00

So I’m trying to integrate the PHP facebook SDK/API with codeigniter, because I love

  • 0

So I’m trying to integrate the PHP facebook SDK/API with codeigniter, because I love codeigniter, but for some reason I keep losing my facebook session as soon as I change pages from my base URL, I have printed the $_session and all i get is Array ( [fb_339393762762289_state] => cb8c201ed66ebcaa60407114aa92f001 ) any ideas why this is happening?

Here is what my controller looks like:

class Main extends CI_Controller {

var $user;
var $log_in_url;
var $log_out_url;

function __construct() {
    parent::__construct();
    $this->load->library('facebook');
    $perams = array(
        'scope' => 'user_about_me, read_friendlists',
        'redirect_uri' => 'http://www.example.com/'
    );
    $this->user = $this->facebook->getUser();
    $this->log_out_url = $this->facebook->getLogoutUrl();
    $this->log_in_url = $this->facebook->getLoginUrl($perams);

    print_r($this->user);
    print_r($this->log_out_url);
    print_r($this->log_in_url);
}

public function index() {
    if ($this->user) {
        try {
            $data['user_profile'] = $this->facebook->api('/me');
        } catch (FacebookApiException $e) {
            error_log($e);
            $this->user = null;
        }
    }

    if ($this->user) {
        $data['logout_url'] = $this->log_out_url;
    } else {
        $data['login_url'] = $this->log_in_url;
    }
    $data['user'] = $this->user;
    $this->load->view('templet/header', $data);
    $this->load->view('main view');
    $this->load->view('templet/footer');
}

  public function account() {

  if ($this->user) {
  try {
  $data['user_profile'] = $this->facebook->api('/me');
  } catch (FacebookApiException $e) {
  error_log($e);
  $this->user = null;
  }
  }

    if ($this->user) {
        $data['logout_url'] = $this->log_out_url;
    } else {
        $data['login_url'] = $this->log_in_url;
    }
  $data['user'] = $this->user;
  $this->load->view('templet/header', $data);
  $this->load->view('account');
  $this->load->view('templet/footer');
  }

from what I can understand from the source code of the api is that it is in charge of handling sessions, so I don’t understand why it keeps losing it.

I was thinking it could maybe have something to do with my Htaccess set up.. Ie. my url when i change pages looks like this http://www.example.com/index.php/controller_name/method_name/

also do i need to do anything with the $_GET vars? because that is one thing i noticed.. there seem to be some things passed in the URL, but they don’t continue on to other pages.

any help on this would be greatly appreciated. I am really at a loss.

  • 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-29T11:03:11+00:00Added an answer on May 29, 2026 at 11:03 am

    my problem was somewhat simple, I kept loosing my session data any time I changed pages, and it tuns out the solution was quite simple. in the config file of CI you have to put you websites base URL, and I put and the session was being created for http://www.mysite.com/ so the php sdk/api created one session for the first url and another for the second.. thus i lost all of the data as soon as i changed pages. so it’s a simple problem, but took a lot of trouble shooting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,

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.