How to use PHP & Session ($_SESSION,$HTTP_SESSION_VARS)
How to use PHP & Session ($_SESSION,$HTTP_SESSION_VARS) Learn PHP how to using Session and read a php variable , Create Session , Read Session , Delete/Clear Session
ShotDev Focus:
- Create Session
- Read Session
- Delete/Clear Session
- Create Session
- Read Session
- Delete/Clear Session
Example
php_session1.php (Create Session)
- <?
- session_start();
- $_SESSION["strName"] = "Mr.Weerachai Nukitra";
- $_SESSION["strSiteName"] = "ShotDev.Com";
- session_write_close();
- ?>
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- Session Created.<br><br>
- <a href="php_session2.php">Check Session</a>
- </body>
- </html>
php_session2.php (Read Session)
- <?
- session_start();
- ?>
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- Session Check.<br>
- session_id(); = <?=session_id();?><br>
- $strName = <?=$_SESSION["strName"];?><br>
- $strSiteName = <?=$_SESSION["strSiteName"];?><br>
- <br>
- <a href="php_session3.php">Delete Session.</a>
- </body>
- </html>
php_session3.php (Clear Session)
- <?
- session_start();
- //unset($_SESSION["strName"]); // Delete Single Session
- //unset($_SESSION["strSiteName"]); // Delete Single Sessionn
- session_destroy(); // Delete All Session
- ?>
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- Created Check.<br>
- $strName = <?=$_SESSION["strName"];?><br>
- $strSiteName = <?=$_SESSION["strSiteName"];?><br>
- <br>
- <a href="php_session1.php">Create Session</a><br>
- <a href="php_session2.php">Check Session</a><br>
- </body>
- </html>
Create a php file and save to path root-path/myphp/
Screenshot
.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment