Sharp Tutorial
session in php

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

PHP Introduction

  • PHP home
  • PHP introduction
  • How to install and run
  • Syntax and Rule in PHP
  • Data type and operator
  • If else in php
  • Loop in php
  • Array in php
  • Sring in php
  • Function in php
  • Include in php

Working with Forms

  • Get and Post
  • Get Form input into PHP
  • Form Validation

PHP with MySQl

  • Connect PHP & Mysql
  • Insert using PHP Mysql
  • Select using PHP MySql
  • Delete Update using PHP Mysql
  • Login Page Example in PHP

Advanced PHP

  • Session in PHP
  • Cookies in PHP
  • File Handling in PHP
  • File Upload/Download PH

Object Oriented PHP

  • Class Obejct in PHP
  • Constructor in PHP
  • Destructor in PHP
  • Inheritance in PHP

session in php

Session is used to store some values on different pages without permanent storage like in database . Some variable may have session values and those values may be accessed on next pages till the session is not destroyed.

Store values in Session variable in php

<?php
  session_start();
$_SESSION['course']="PHP";
$_SESSION['topic']="Session";
?>
<a href="session-get.php">Go To Session Get Page</a>

 

Now we can access these session variable on other page as following.

<?php
  session_start();
echo "Course: =".$_SESSION['course'];
echo"<br> Topics in course:= ".$_SESSION['topic'];
?>
<br><a href="session-get.php">Go To Next Page to unset session variable</a>

 

Destroy the session and unset the session variable

<?php
  session_unset();
session_destroy();
echo"Course:= ".$_SESSION['course']"; // this line will give an error
?>

 

As session variable are unset so they can not access and it gives error on this page as follows

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial