How to use session in PHP?

Total Post:412

Points:2888
PHP 
PHP
 2254  View(s)
Ratings:
Rate this:
Hi,
I want to show page view in my php page, So could you explain how to solve this problem using session. Please reply as soon as possible.

  1. Post:68

    Points:476
    Re: How to use session in PHP?

    Hello Pravesh,
    A PHP session variable is used to store information about, or change settings for a user session. Before you can store user information in your PHP session, you must first start up the session. session_start() function is used for start session into PHP page.

    To resolve your problem you can try something like following code.
    PHP Script Code:

            <?php
            //  Start  Session 
        
            session_start();
            //  check  session  value  has  been  set  or  not
            if(isset ($_SESSION['PageViewUser']))
            {
        // increment counter by 1 if session value is already set
        $_SESSION['PageViewUser'] = $_SESSION['PageViewUser']+ 1 ;
    } else {
        // if session value not set, then value set by 1 in session variable
        $_SESSION['PageViewUser'] = $_SESSION['PageViewUser']+1 ;
    } ?>

    For more details about Session or Session Variable in PHP visit this URL:
    http://mindstick.com/Articles/660ef403-4dff-4ed7-8199-dc6daafb1ee7/?PHP%20Session

      Modified On Mar-29-2018 05:07:07 AM

Answer