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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:51:39+00:00 2026-05-23T02:51:39+00:00

I have a question about PHP sessions. I use a session to keep a

  • 0

I have a question about PHP sessions. I use a session to keep a visitor logged in. I have made a site before with this and works perfect. Now I am making a Facebook app.

When logging in (checking if user is registered in database), I register id. After that I use:

if(session_is_registered("id"))
{
echo "Logged in";
}

So if it shows “Logged in” in the browser, I am absolutely sure that the session is registered. But when I go to the next page (which has session_start(); at the top of the page), there’s no session anymore. But if I go to the logout page (with session_destroy();), and then proceed to the login, the session is registered correctly. Also if I close all the browser windows and then go to login, it won’t register correctly.

I tried destroying the session right before registering the ‘id’, but that also doesn’t work.

I’m guessing I made a basic error, so someone on here should be able to help me without wasting a lot of time.

Please help me. I have wasted days on this.
Thanks in advance.


More code:

Where session is registered:

$id_query = mysql_query ("
    SELECT * FROM Tour11_deelnemers WHERE fb_id = '$user'");
    while ($record = mysql_fetch_assoc ($id_query))
        {
        $id = $record['deelnemer_id'];
        }
if($id > 0)
{
$speelid = $id;
session_register("speelid");
}

After that to check if it is registered:

if(session_is_registered("speelid"))
{
echo "Ingelogd";
}

session_is_registered() is same as isset() for $_SESSION.

So the thing I don’t understand is while session_is_registered() is true after it is registered, on the next page it is false again 🙁 unless I login immediately after going to logging out page (session_destroy();). So even if i destroy the session just before restarting it and registering again, it doesn’t help.

  • 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-23T02:51:39+00:00Added an answer on May 23, 2026 at 2:51 am

    Here is a solution for you.

    Set the session like this:

    if(!isset($_SESSION['speelid'])){
       $id_query = mysql_query ("SELECT * FROM Tour11_deelnemers WHERE fb_id = '$user'");
            while ($record = mysql_fetch_assoc ($id_query)){
                $id = $record['deelnemer_id'];
            }
        if($id > 0){
            $_SESSION['speelid'] = $id;
        }
    }
    

    Check if a session is set like this:

    if(isset($_SESSION['speelid'])){
        echo "Ingelogd";
    }
    

    Update

    It seems like the issue is related to >= IE6 refusing to accept the session cookie generated by the php, when a .php file is referred from an .html file on a different server.

    .HTML to .PHP session IE issue

    When using session
    variables in a .php file referred by a
    frame (.html, or other file type) at a
    different server than the one serving
    the .php:

    Under these conditions IE6 or later
    silently refuses the session cookie
    that is attempted to create (either
    implicitly or explicitly by invoquing
    session_start()).

    As a consequence, your session
    variable will return an empty value.

    According to MS kb, the workaround is
    to add a header that says your remote
    .php page will not abuse from the fact
    that permission has been granted.

    Place this header on the .php file
    that will create/update the session
    variables you want:

    Here is a full thread on this issue

    Solution

    The solution is to add this at the very top of the page which will SET the session.

    <?php header('P3P: CP="CAO PSA OUR"'); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A quick question about best practice with PHP classes. I have seen people use
I have a question about locking. This doesn't have to be only about record
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
I have a question about this question . I posted a reply there but
I have a question about design winforms. Should I use, or not, group boxes
everyone! i have a question about sessions hopefully someone can help me with. I
I have a question about the use off the http api from the company
I have a question about the way in which the output is displayed. <?php
Hi I am new to php eclipse and I have a question about my
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and

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.