Function session_is_registered() and Cannot modify header information - headers already sent by
<p>I am trying to create an admin page with sessions. I get the following two errors from admin.php. </p>

<pre><code>Deprecated: Function session_is_registered() is deprecated in /home/content/95/10216895/html/test/admin.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at /home/content/95/10216895/html/test/admin.php:4) in /home/content/95/10216895/html/test/admin.php on line 7
</code></pre>

<p>The code looks like this:</p>

<pre><code>&lt;?php
  //Start the session
  session_start();
  //Get the user name from the previously registered super global variable
  define(ADMIN, $_SESSION['name']);

  if (!session_is_registered("admin"))
  {
    //If session not registered, redirect to login.php page
    header("location:login.php");
  }
  else
  {
    header( 'Content-Type: text/html; charset=utf-8' );
  }
?&gt;


&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;&lt;head&gt;
</code></pre>

<p>The login check code which is in another file check_login.php for setting the variable is below:</p>

<pre><code>    $sql="SELECT * FROM login_admin WHERE user_name='$myusername' and user_pass=SHA1('$mypassword')";
    //echo '&lt;p&gt;'.$sql.'&lt;/p&gt;';

    $result=mysqli_query($dbC, $sql);
    //echo '&lt;p&gt;'.$result.'&lt;/p&gt;';

    // Mysql_num_row is counting table row
    $count=mysqli_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row
    if ($count==1)
    {
      // Register $myusername, $mypassword and redirect to file "admin.php"
      session_start();
      $_SESSION['name'] = 'admin';
      $_SESSION['password'] = 'password';
      // session_register("admin");
      // session_register("password");
      // $_myusername= $myusername;
      $_SESSION['name']= $myusername;
      header("location:admin.php");
    }
</code></pre>

<p>Can any one help me to solve this issue?</p>
