91-9990449935 0120-4256464 |
PHP SessionPHP session is used to store and pass information from one page to another temporarily (until user close the website). PHP session technique is widely used in shopping websites where we need to store and pass cart information e.g. username, product code, product name, product price etc from one page to another. PHP session creates unique user id for each browser to recognize the user and avoid conflict between multiple browsers. PHP session_start() functionPHP session_start() function is used to start the session. It 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 Example PHP $_SESSIONPHP $_SESSION is an associative array that contains all session variables. It is used to set and get session variable values. Example: Store information Example: Get information PHP Session ExampleFile: session1.php File: session2.phpPHP Session Counter ExampleFile: sessioncounter.phpPHP Destroying SessionPHP session_destroy() function is used to destroy all session variables completely. File: session3.php
Next TopicPHP File
|