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

COMPUTER SOFTWARE APPLICATION - CITS



           II  Decoding session variables
              1  Open the text editor
              2  Write the following codes

                                 <html>
                                 <body>
                               <?php
                 // Start the session
                               session_start();



                    if (isset($_SESSION[‘encoded_username’]))
                    {
                              $encodedUsername = $_SESSION[‘encoded_username’];

                                      //decode using base64_decode()
                              $decodedUsername = base64_decode($encodedUsername);
                                               echo “Decoded Username: $decodedUsername”;
                                       }
                                       else
                                       {

                                               echo “Session variable ‘encoded_username’ not set.”;
                                       }?>
                       </body>
                                </html>

              3. Save the program in C:\Apache24\htdocs in a folder with .php extension
              4. Run the Apache services from windows services
              5. Open the browser and type the following address
                                     http://localhost/foldername/
              6  Click the php file to run  and verify the output


















           TASK 9: Destroying a session
              1  Open the text editor
              2  Write the following codes







                                                           264
                                CITS : IT & ITES - Computer Software Application - Exercise 54
   274   275   276   277   278   279   280   281   282   283   284