How can we register the variables into a Session?

Answer Posted / animesh dutta

<?php
// Start the session
session_start();
?>
<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When to use get and post request?

553


What are the differences between session and cookie?

523


What is cookie and why do we use it?

531


What is echo in html?

501


Which is the dependent variable?

494






How to copy a file?

565


What is filter_var?

536


Is php used in 2019?

537


Is json a string php?

526


How To Get the Uploaded File Information in the Receiving Script?

591


When do sessions end?

546


What does session start do in php?

509


Are php variables global?

562


What is list function with their uses.

533


Why do we use csrf token?

519