top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to create our own session in php?

0 votes
313 views

Give some sample code for creating session in php.Also,provide some sample link for learning about session in php.

posted Sep 29, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

For creating session first you need to start the session by using below code

session_start(); 

Then using $_SESSION we can create a session variable.

Example Code:

<?php session_start(); // store session data $_SESSION['views']=1; ?>

<html>
<body>

<?php
//retrieve session data
echo "Pageviews=". $_SESSION['views'];
?>

</body>
</html>

More Reference visit -> http://www.w3schools.com/php/php_sessions.asp

answer Sep 30, 2014 by Sandeep Bedi
Similar Questions
...