Page 274 - Computer Software Application TP - Volume 1
P. 274
COMPUTER SOFTWARE APPLICATION - CITS
$username = $_SESSION[‘username’];
$user_email = $_SESSION[‘user_email’];
// Display session variables
echo “Username: $username <br>”;
echo “Email: $user_email <br>”;
// Modify session variable
$_SESSION[‘user_email’] = ‘john.doe@example.com’;
// Display modified session variable
echo “Modified Email: “ . $_SESSION[‘user_email’] . “<br>”;
?>
</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 6: Passing session ID
I Pass Session ID using URLs
1 Open the text editor
2 Write the following codes
<html>
<body>
<?php
session_start();
$sessionId = session_id();
echo “Session ID: $sessionId<br/>”;
echo “<a href=’next_page.php?PHPSESSID=$sessionId’>Next Page</a>”;
?>
259
CITS : IT & ITES - Computer Software Application - Exercise 54 CITS : IT & ITES - Computer Software Application - Exercise 54