session_id() isn't output anything on PHP
<p>I have two pieces of codes one is the front end website php code that render the front end web pages  and another is the backend api PHP code.  On my front end website code I have <strong>session_start()</strong>;</p>

<p>I have a piece of back end API code that once a user login then I give him or her a <strong>sessionid</strong> by doing <code>sessionid();</code> </p>

<p>However, when I use <code>$sessionid = session_id();</code> and <code>echo $sessionid</code>, nothing's outputted.</p>

<pre><code>$user="root";
$password="";
$database="test";
mysql_connect('localhost',$user,$password);
@mysql_select_db($database) or die( "Unable to select database");

$username = $first_param;
$username = str_replace( "UserName=", "", $username);
$password = $second_param;
$password = str_replace( "Password=", "", $password);
$query = "SELECT * FROM `user` WHERE username ='$username' AND password = '$password' ";
$result=mysql_query($query);
$num=mysql_num_rows($result);

if (debug) {
  echo "&lt;br&gt;";
  echo "--------the num of login is ----" .$num;
}

if ($num &lt;1) {

}
else {
  $sesid=session_id();
  if (debug) {
    echo "&lt;br&gt;";
    echo "-----login sessionid is------" .$sesid;
    echo "&lt;br&gt;";
  }
  $query = "UPDATE `user` SET sessionid='$sesid' WHERE username ='$username' AND password = '$password'";
  mysql_query($query);
}
</code></pre>
