using session control in php n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 23 PowerPoint Presentation
Download Presentation
Chapter 23

Loading in 2 Seconds...

play fullscreen
1 / 11

Chapter 23 - PowerPoint PPT Presentation


  • 83 Views
  • Uploaded on

Using Session Control in PHP. Chapter 23. No built in way of maintaining a state between two transactions. HTTP is a stateless protocol. Unique session ID – random number Generated by PHP Stored on client for the lifetime of the session Stored as a cookie. PHP Sessions. <h1>Page 1</h1>

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Chapter 23' - thuyet


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
php sessions

Unique session ID – random number

Generated by PHP

Stored on client for the lifetime of the session

Stored as a cookie

PHP Sessions
page1 php

<h1>Page 1</h1>

<?php

session_start();

$_SESSION['sess_var'] = "Hello World";

echo 'The contents of $_SESSION[\'sess_var\'] is '

.$_SESSION['sess_var'].'<br />';

?>

<a href="page2.php">Next page</a>

Page1.php
session variables

Superglobal array $_SESSION

  • To create a session variable:
    • $_SESSION[‘id’] = 99;
  • When finished
    • unset($_SESSION[‘id’]);
Session variables
page1 php1

<h1>Page 1</h1>

<?php

session_start();

$_SESSION['sess_var'] = "Hello World";

echo 'The contents of $_SESSION[\'sess_var\'] is '

.$_SESSION['sess_var'].'<br />';

?>

<a href="page2.php">Next page</a>

Page1.php
page2 php

<h1>Page 2</h1>

<?php

session_start();

echo 'The contents of $_SESSION[\'sess_var\'] is '

.$_SESSION['sess_var'].'<br />';

unset($_SESSION['sess_var']);

?>

Page2.php
page3 php

<h1>Page 3</h1>

<?php

session_start();

echo 'The contents of $_SESSION[\'sess_var\'] is '

.$_SESSION['sess_var'].'<br />';

session_destroy();

?>

Page3.php