Stats: 3,186,763 members, 7,930,631 topics. Date: Sunday, 25 August 2024 at 12:09 AM |
Nairaland Forum / Science/Technology / Webmasters / Practical Use Of Session In PHP (478 Views)
Intel Host Bloggers Hangout Session In Nigeria / 7 Practical Ways Through Which You Can Earn Massively In Blogging / What's The Difference Between "require Once" And "include" In Php? (2) (3) (4)
(1) (Reply)
Practical Use Of Session In PHP by maekhel(m): 8:39pm 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)
Make Money Online Like 1k Everyday / Web Hosting In Lagos / Author Needed At Scannewsonline Payment Involved!!!
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8 |