How to use session in PHP?

Total Post:412


 2417  View(s)
Rate this:
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. 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:

            //  Start  Session 
            //  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:

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


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.