since PHP can’t be used in Spotify apps directly I am using it on my server only, but I am having problems getting the sessions to work, is it possible to use sessions even?
I want to use it to see if a user is registered in my database or not so I am doing it like this:
session_start();
$query="SELECT * FROM user WHERE facebookID = {$fbid}";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$num_results = mysql_num_rows($result);
if ($num_results > 0)
{
echo"THERE IS A USER!";
$row['facebookID'] = $_SESSION[fid];
}
else
{
echo"THERE IS NO USER!";
}
the authentication to the server works fine but the session does not seem to be working, on another PHP page witch is being called after the above code has been called with some ajax code I simply wanted to try this:
session_start();
if(isset($_SESSION['fid']))
{
echo"SESSION EXIST";
}
else
{
echo"NO SESSION";
}
anyways is there a special way to do this in Spotify apps or do I have to do this in some other way?
Where do you set
$_SESSION[fid]to be the FacebookID?Maybe you should do this:
BTW always put quotes around the key names when you access arrays in PHP, like this:
$_SESSION['fid']not$_SESSION[fid], otherwise PHP will first check for constant named “fid” then cast to string – its slower and more important – uglier and bad practice.