/
Chapter 23 Chapter 23

Chapter 23 - PowerPoint Presentation

test
test . @test
Follow
374 views
Uploaded On 2016-08-06

Chapter 23 - PPT Presentation

Using Session Control in PHP HTTP is a stateless protocol No built in way of maintaining a state between two transactions PHP Sessions Unique session ID random number Generated by PHP Stored on client for the lifetime of the session ID: 434624

php session sess var session php var sess page start echo page1 contents page2 stored create destroy world

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Chapter 23" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Chapter 23

Using Session Control in PHPSlide2

HTTP is a stateless protocol

No built in way of maintaining a state between two transactionsSlide3

PHP Sessions

Unique session ID – random number

Generated by PHP

Stored on client for the lifetime of the session

Stored as a cookieSlide4

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>Slide5

Start_session

Checks to see whether there is a current session.

If not, it not it will create one.Slide6

Session variables

Superglobal

array $_SESSION

To create a session variable:

$_SESSION[‘id’] = 99;

When finished

u

nset($_SESSION[‘id’]);Slide7

Finish the session

session_destroy

( );Slide8

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>Slide9

Page1.php

http://

cscdb.nku.edu/csc301/frank/Chapter23/page1.php

Slide10

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

']);

?>Slide11

Page3.php

<h1>Page 3</h1>

<?

php

session_start

();

echo 'The contents of $_SESSION[\'

sess_var

\'] is '

.$_SESSION['

sess_var

'].'<

br

/>';

session_destroy

();

?>