PHP Session

Hi Guys! Today I am going to talk about what "PHP Session" is.


So what really is a PHP Session?

Think of a situation where you open an application to do some modification and then close it. So here the computer knows what we really did. But when it comes to internet, the web server does not know what you did. That's where sessions comes in handy. Session variables can stay until you close your browser.

Session is a way to store information across multiple pages.

Now how comes a session variable starts?


Session variables starts with the session_start() function
Session variables are stored in associative array called $_SESSION[].

Now take a look at below example.

In here, I have start a new PHP session and set session variables.




Let's Now see how to destroy a PHP session!


To destroy the session use session_destroy() function.
To remove all global session variables use unset() function.



Have a Great Future with PHP !
Thank you! 


Comments

Popular Posts