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

COMPUTER SOFTWARE APPLICATION - CITS



                       $username = $_SESSION[‘username’];
                       echo “Welcome back, $username!”;
                 }

                 else
                 {
                       echo “Session not found!”;
                 }
              ?>

                    </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 8: Encoding and decoding session variables
           I  Encoding session variables

              1  Open the text editor
              2  Write the following codes
                              <html>
                              <body>
                            <?php
              // Start the session
                           session_start();
                 $username = ‘JohnDoe’;
                           //encode using base64_encode()
                 $encodedUsername = base64_encode($username);
                 $_SESSION[‘encoded_username’] = $encodedUsername;?>
                    </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

















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