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

COMPUTER SOFTWARE APPLICATION - CITS



           TASK 4: Starting a session

              1   Open the text editor
              2   Write the following codes
                              <html>
                              <body>
                      <?php

              // Start the session
              session_start();
              echo”Session started with this id :  “. session_id();
              // Now you can set session variables

              $_SESSION[‘username’] = ‘example_user’;
              $_SESSION[‘is_logged_in’] = true;
                ?>
              </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 5: Working with session variables
           1  Open the text editor

           2  Write the following codes
                              <html>
                              <body>
                      <?php
              // Start the session

              session_start();
              // Set session variables
              $_SESSION[‘username’] = ‘john_doe’;
              $_SESSION[‘user_email’] = ‘john@example.com’;
              // Access session variables






                                                           258
                                CITS : IT & ITES - Computer Software Application - Exercise 54
   268   269   270   271   272   273   274   275   276   277   278