Page 276 - Computer Software Application TP - Volume 1
P. 276

COMPUTER SOFTWARE APPLICATION - CITS




















           III  Retrieve Session ID on the Next Page
           1  Open the text editor
           2  Write the following codes

                           <html>
                           <body>
                  <?php
                         session_start();
                         if (isset($_GET[‘PHPSESSID’]))
                         {
                                        // If passed in the URL
                                         $sessionId = $_GET[‘PHPSESSID’];
                         }
                         elseif (isset($_POST[‘PHPSESSID’]))
                         {
                                        // If passed in a form
                                         $sessionId = $_POST[‘PHPSESSID’];
                                  echo $sessionId .“This session ID retrieved”;
                         }
                         else
                         {
                                         // If not explicitly passed, the session ID is already handled by PHP
                                        $sessionId = session_id();
                         }
                    ?>
           </body>
           </html>
           3  Save the program in C:\Apache24\htdocs in a folder with .php extension





















                                                           261
 CITS : IT & ITES - Computer Software Application - Exercise 54   CITS : IT & ITES - Computer Software Application - Exercise 54
   271   272   273   274   275   276   277   278   279   280   281