₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,326,361 members, 8,426,235 topics. Date: Saturday, 13 June 2026 at 10:18 PM

Toggle theme

Practical Use Of Session In PHP - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPractical Use Of Session In PHP (801 Views)

1 Reply

Practical Use Of Session In PHP by maekhel(op): 8:48pm On Nov 06, 2014
In my last post I talked about <a href="http://
tutorialslodge.com/session-php">Session In PHP</
a>. Today I will be discussing Practical Use Of
Session In PHP. This is going to be a straight
forward tutorial, we are going store information in
session and use the information across multiple
pages. So let get started.
Open your favorite text editor (Notepad), paste the
code below in it and save as page1.php
[code lang="php"]
<?php
session_start(); //start session
$_SESSION['username'] = "mezie"; //store
information in the session variable
?>
[/code]
The code is quite straight forward. We starts the
session and assigned a string to a session variable.
Next, create another file and name it page2.php.
Paste the code below in it.
[code lang="php"]
<?php
session_start(); //start session
echo "My Username is ".$_SESSION['username']
; //display information in the session variable
?>
[/code]
When you run the code above in your browser, you
will see <strong>My Username is Mezie</strong>.
As you can see the string (mezie) has being made
available to page2.php with the help of session.
This is just one out of the numerous ways session
can be used. I hope this tutorial was helpful. Feel
free to drop your comment or questions in the
comment box below.
source: http://tutorialslodge.com/practical-use-
session-php/
1 Reply

Can Blog Be Develope From Scratch Without The Use Of Wp Or Blogger?Session In PHPRunning Python Codes In Php234

Javascript— The Dark Parts: The ScopeOnline Programming TutorialUsing Php To Create A Form