php session n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
PHP Session:How to start sessions in PHP PowerPoint Presentation
Download Presentation
PHP Session:How to start sessions in PHP

Loading in 2 Seconds...

play fullscreen
1 / 6

PHP Session:How to start sessions in PHP - PowerPoint PPT Presentation


  • 2 Views
  • Uploaded on

PHP Session provides the facility for storing the information which can be used across the webpages.

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 'PHP Session:How to start sessions in PHP ' - eitworld5


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 session

PHP Session:

PHP Session provides the facility for storing the information which can be

used across the webpages. Session In PHP is that if you log in some site and

spend some time on it and after some time you logged out from site then

time duration from login and logout is nothing but it is a session.

In PHP you can start a session by using the session_start() function and can

use the session for storing the information in the session variables using

$_SESSION[“variableName”];

How to start PHP sessions:

session_start() is used to start the PHP session. Here is the example of session

in php is as follows:

<?php

// Start the session

session_start();

?>

<!DOCTYPE html>

<html>

<body>

<?php

// Set session variables

$_SESSION["user"] = "king";

$_SESSION["pass"] = "123";

echo "Session are set.";

?>

</body>

</html>

the output is as follows

The output is as follows:

How to get PHP session values:

You can get all the session values on any php page. The following example

shows you the demo:

<?php

session_start();

?>

<!DOCTYPE html>

<html>

<body>

<?php

// Echo session variables that were set on previous page

echo "user name is : " . $_SESSION["user"] . ".<br>";

echo "password is : " . $_SESSION["pass"] . ".";

body html

?>

</body>

</html>

The output is as follows:

Another way to display session value:

Print_r($_SESSION); is used to print all the session variable values. The

example of this is as follows:

<?php

session_start();

?>

<!DOCTYPE html>

<html>

<body>

php print r session body html

<?php

print_r($_SESSION);

?>

</body>

</html>

The output is as follows:

Modify the session variable values:

You can change the value for session variables. The example to change the

session variables are as follows:

<?php

session_start();

?>

<!DOCTYPE html>

<html>

body php to change a session variable session

<body>

<?php

// to change a session variable

$_SESSION["user"] = "varshney";

print_r($_SESSION);

?>

</body>

</html>

Here we have changed the user session value. Now output is as follows:

How to destroy the session:

Session_unset() function used for removing session variables and

session_destroy() is used to remove the session. The example shows you how

to remove the session:

php session start doctype html html body

<?php

session_start();

?>

<!DOCTYPE html>

<html>

<body>

<?php

// it remove all session variables

session_unset();

// it destroy the session

session_destroy();

?>

</body>

</html>

For more information visit: https://www.bebee.com/producer/@eit-world/php-

session-how-to-start-sessions-in-php