WPPM Unit-1
WPPM Unit-1
Usage of function:-
i. Reducing repetition:
User defined function enables developer to extract commonly
used pieces of code as separate package. So it reduces
unnecessary code repetition and redundancies also makes the
code easier to understand and debug.
invoking function
<?php
….
….
displayShakesphearQuote();
?>
<!DOCTYPE html>
<html>
<body>
<?php
// Echo session variables that were set on previous page
echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";
echo "Favorite animal is " . $_SESSION["favanimal"] . ".";
?>
</body>
</html>
Sunday, 21 January 2024 GIET UNIVERSITY, GUNUPUR
Sessions :-
Another way to show all the session variable values for a user
session is to run the following code:
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
print_r($_SESSION);
?>
</body>
</html>
Example
<?php
$cookie_name = "user";
$cookie_value = "Atul Kailash";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30),
"/");
?>