Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP session doesn't work correctly maybe because of fb? please help
    text
    copied!<p>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.</p> <p>When logging in (checking if user is registered in database), I register <code>id</code>. After that I use:</p> <pre><code>if(session_is_registered("id")) { echo "Logged in"; } </code></pre> <p>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.</p> <p>I tried destroying the session right before registering the 'id', but that also doesn't work.</p> <p>I'm guessing I made a basic error, so someone on here should be able to help me without wasting a lot of time.</p> <p>Please help me. I have wasted days on this. Thanks in advance.</p> <hr> <p>More code:</p> <p>Where session is registered:</p> <pre><code>$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 &gt; 0) { $speelid = $id; session_register("speelid"); } </code></pre> <p>After that to check if it is registered:</p> <pre><code>if(session_is_registered("speelid")) { echo "Ingelogd"; } </code></pre> <p>session_is_registered() is same as isset() for $_SESSION.</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload