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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:12:41+00:00 2026-05-30T23:12:41+00:00

I am new to PHP and am trying to build a facebook application. In

  • 0

I am new to PHP and am trying to build a facebook application. In the index.php file, I do the following :

if(!isset($_SESSION)){ 
       session_start(); 
}

the facebook sdk seems to start the session by itself, so my code, doesn’t get called at all ! meanwhile, index.php has a form that gets submitted to a new file called processForms.php. In index.php, i set the following:

$_SESSION['uid'] = $me['id'];

But in processForms.php, accessing $_SESSION gives me the following error:

Notice: Undefined variable: _SESSION

Not sure whether I am getting the whole concept of sessions wrong here.

  • 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-30T23:12:42+00:00Added an answer on May 30, 2026 at 11:12 pm

    You don’t need an if before session_start. Just call it straight: session_start();. If the session has already been started, it will do no harm.

    It seems you get the concept of “starting the session” wrong. Well, not exactly wrong… Look: “session_start()” does not “starts the session”, in the sense you may be thinking, i.e., you call it once and the “session has been ‘started'”. No. You need to call “session_start” always, in the beginning of every PHP script which will deal with sessions.

    For example, at login.php:

    session_start();
    if ($user_and_pass_are_correct)
    {
        $_SESSION['username'] = $username;
    }
    

    At somepage.php:

    session_start();
    echo 'User name is ' . $_SESSION['username'];
    

    You need the “session_start” call there. It does not mean “the beginning of the session”. It means “initialize the session stuff, so I can use sessions”.

    An usual approach is to have a single session_start in a “bootstrap” kind of script, and include it in the beginning of all other scripts.

    “bootstrap.php“

    <?php
        session_start(); // first line of script
        initialize_other_stuff();
    

    “a_page.php“

    <?php
        include('bootstrap.php'); // first line of script
    

    “another_page.php“

    <?php
        include('bootstrap.php'); // first line of script, always
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to build an Facebook Application based on PHP. The Application is running
I am new to PHP and trying to get the following code to work:
I am very new to php, and I am trying to develop a facebook
I am trying to use the new facebook api and it requires libcurl PHP.
I am new to php and am trying to build a website. I would
I am new to PHP and was trying to build RestFull service in PHP
I am new to php and trying to write a login function. Bit stuck
I'm new to PHP and trying to get my head around security. I have
I am pretty new to PHP and I am trying to make an inventory
I am new to php and I am getting this error trying to load

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.