How To Enable Session In The Browser

Table of contents:

How To Enable Session In The Browser
How To Enable Session In The Browser
Anonim

Since the web server does not maintain continuous communication with the client, and each request is perceived by the server as a new one, the main task of sessions in a browser is to identify the browser and create a corresponding file that stores session variables.

How to enable session in the browser
How to enable session in the browser

Instructions

Step 1

A session is essentially a text file that stores the values of the request-response pairs on the server. The number of such files for different clients can be very large, so each client is assigned its own SID, which is transmitted using the query string. Sessions and cookies are information storage methods used to identify a user. At the same time, the former are saved on the server and used by the administrator, while the latter are determined by the developer and stored on the local computer.

Step 2

Session activation in the browser is set by the dool session_start () command on each resource containing a call to variables. In this case, the response of the function true symbolizes the successful activation of the session, and the response false - an error. After enabling the session, you can save the data in the $ _SESSION array.

Step 3

Please note that the session.save_path command located in the php.ini file defines the path to where the session files are saved. The ambiguity of this directive implies automatic saving of session files in the server's RAM. The "lifetime" of a session is defined by the session.cookie_lifetime directive in the same php.ini configuration file.

Step 4

Disabling the browser session function is set by the bool session_destroy () function. The string session_id ([$ id]) function allows you to determine the current session identifier.

Step 5

An additional feature of this function is the ability to set your own session identifier using the optional $ id parameter. Please note that the use of Cyrillic characters in this parameter is not allowed, unlike numeric characters. Another condition for the success of setting your own session identifier is the need to use the session_start () function.

Recommended: