---
title: "How to use session in PHP?"  
description: "How to use session in PHP?"  
author: "Pravesh Singh"  
published: 2012-03-12  
updated: 2026-05-15  
canonical: https://www.mindstick.com/forum/394/how-to-use-session-in-php  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# How to use session in PHP?

Hi,\
I want to show [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) [view](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) in my [php](https://www.mindstick.com/articles/12149/php-constant-and-php-variables) page, So could you [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) how to [solve this problem](https://answers.mindstick.com/qa/94681/my-google-assistant-shows-completely-different-search-results-from-what-i-ask-how-can-i-solve-this-problem) using session. Please reply as soon as possible.\
\

## Replies

### Reply by Anonymous User

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](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) 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\
\


---

Original Source: https://www.mindstick.com/forum/394/how-to-use-session-in-php

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
