Contact Us || Privacy Policy || About Us |
|
Session in PHP⟼ PHP session is used to store and pass information in variables to be used across multiple pages.: ⟼ In PHP session creates unique user id for each browser to recognize the user and avoid conflict between multiple browsers. You can see example of shopping website where store username, product code, product name, product price etc. How Session Works![]() Start Session in PHPIn PHP in-built a function named as session_start() this function starts a new or resumes existing session.It returns existing session if session is created already. If session is not available, it creates and returns new session.. Syntax PHP $_SESSION$_SESSION is used to set and get session variable values. Example:-File name :- session1.php File name :- session2.php Output:- ![]() ![]() Session Counter Example in PHPFile name :- SessionCounter.php Output:- ![]() PHP Session Destroysession_destroy() funtion is used to destroy all session. Example:- sessiondis.php Output:- ![]() |