hello im a newbie in PHP session. I do have problem in killing session.
here is the source code for
session.php

<?
if (!session_id()))

session_start();
$sessions_id=session_id();

}
?>
<HTML>

<body>

</body>
</html>

how can i kill this session in other php

when i click on HOMe

    session_unregister()

      <?php
      session_start();
      unset($_SESSION['your session name here']);

      // you can destroy multiple session variables too

      unset($SESSION['your session name here']);
      unset($
      SESSION['your session name here']);

      // so far you have only unset specific session variables
      // you can completely destroy the session with:

      session_destroy();

      // now to send them to your home page

      $url = "home.php";
      Header("Location: $url");
      ?>

      call this logout.php and link to it.

      when using sessions 'session_start' must be the very first thing on the page. if not you will just get an error.

        session_unregister() doesnt work when i go back to the session.php the session id value is still the same

          <?
          session_start();
          session_unregister();
          session_destroy();
          $url = "home.php";
          Header("Location: $url");
          ?>

            I just followed your source code
            and here is the error

            Warning: Wrong parameter count for session_unregister() in D:\jan files\program\session\session2.php on line 15

              sorry ...
              session_unset();

              ....
              http://www.php.net/manual/en/function.session-destroy.php

              Example 1. Destroying a session

              <?php

              // Initialize the session.
              // If you are using session_name("something"), don't forget it now!
              session_start();
              // Unset all of the session variables.
              session_unset();
              // Finally, destroy the session.
              session_destroy();

              ?>

              Example 2. Destroying a session with $_SESSION

              <?php

              // Initialize the session.
              // If you are using session_name("something"), don't forget it now!
              session_start();
              // Unset all of the session variables.
              $_SESSION = array();
              // Finally, destroy the session.
              session_destroy();

              ?>

                I didnt use any $_session[]
                just use session_id

                any response will be a big help

                  I assume that you have session_start at the top of all your pages?
                  If this is so consider this, session_start initialises a session whether you use it to store any variables or not.
                  once a session_id has been issued to a user it is held throughout all the pages because of session_start.

                  so even though you destroy that session for a user as soon as they go to another page that has session_start another session is automatically created all over again.

                  the reason you use session_destroy is to ensure that variables stored as session variables are removed from memory.

                  this being, what is the point of your exercise?😕

                    llo there as a response to the session
                    there is only one session_id in my page

                    how can i destroy the session id when and only when I finish my shopping cart ?

                    in my shoppingpge.php

                    <?

                    if (!session_id())
                    session_start();
                    $session_ids=session_id();
                    };

                    ?>

                    <HTML>
                    <body>
                    < a href="submit.php?session=<? echo $sessions_id; ?>" submit here </a>
                    </body>
                    </html>

                    in my submit.php

                    <html>
                    <body>
                    <?

                    $session=$_GET['session'];

                    echo '<a href=" destroy.php"> </a>';
                    ?>
                    </body>
                    </html>

                    in my destroy.php

                    <?

                    session_start();
                    session_unset();
                    session_destroy();
                    session_start();
                    $url="shoppingpge.php";
                    Header("Location: $url");
                    ?>

                    When returned to shoppingpge.php
                    the session_id still the same value

                    🙁 how can i change the value of my session_id

                    ???????

                      Write a Reply...