php session (session)

php session Related:


    1: What is the session?
        The session, ie the session control. Users entering the site to shut down this time elapsed, the user is browsing the site takes time. Therefore to be understood from the above definition, session time is a specific concept.
    2: Why use the session?
        --1: htpp protocol is a stateless protocol: that is a client of this request and the last request do not correspond, http server does not know these two requests from the same client.
            httpt short protocol is connected, the server requests the client sends the corresponding link ends.        
            The advantage is that the server is to reduce the pressure, the disadvantage that every request transfer of large amounts of content information.
        --2: session provides a way to define global variables in php script, making this a global variable in the same session are valid for all the php script files.
            So http server session is a method for maintaining state-based.
        --3: session at http allows the server to keep the session user data throughout the data storage, the session is not only a concept of time, further comprising
            a specific user and the server.
    3: How it works the session:
        1st visit --- "http request, initialization session, create sessionId, will store session data to a predefined variable $ _session in.
            Page finished the session information stored in the session file --- "session file
            http corresponding (with sessionId) - "display page sessionId stored in a cookie
        2nd visit ---" http request (with sessionId)
            the session initialization, sessionId read the files as required.
            Execute php code
            http response --- "display page
            page is finished to store session information to the session file
        Exit ---"
            Notes session, delete the session file.
        
        Session identifier (sesssionId):
            the session identifier is a unique identifier, this identifier can be used to read session_id function. When you enable session state for the php application will check each application page requests are sessionId value sent by the browser.
            If no sessionID value, php will start a new session and the session sessionId value transmitted together with the response to the browser.
            As long as the request has been sent to the same sessionID value, the session is considered active. If the request for a particular session timeout interval exceeds a specified value (in s),
            the session is considered expired. If sessionId value expires transmitted request will generate a new session.
            Default 24 minutes,
    4: the session correlation function:
        --session_start ([aray $ options = [ ]])
            start a new session or reuse an existing session.
            Description:
                1: $ Options parameter is an associative array, if provided, will be covered by one of the project configuration options in the session configuration.
                2: If you via get / POST or by using the cookie session id will be submitted to reuse an existing session.
        --session_id ([string $ id])
            Get / set the current session id
            Description:
                1: If the specified values $ id parameter, the specified value will be used as the session id
                2: Electrophoresis must session_id before calling session_start () function ( ) function
        --session_name ([string $ name])
            read / set session name
            Description:
                1: If the specified parameter $ name, session_name () function updates the session name, session name and returns to the original.
                2: You must call session_start () before electrophoresis session_name function ()
        --session_destroy ()
            Destroy all data in one session session
        
    5: session configuration:
        --session.auto_start (Boolean)
            Specifies whether the session module starts automatically when the start request, the default is 0, no start
        --session.name (string)
            specified session name in the cookie name is used, only alphanumeric, default PHPSESSION
        (String) --session.save_handler
            defined to store and retrieve the name of the processor associated with the session data, default to files. In fact, we can also be stored in the cache database.
        --session.save_path (string)
            parameter to define the storage processor pass, if the default files handler, then the value is the path to the file.
        --session.gc_maxlifetime (integer)
            is specified after the data will be considered junk after how many seconds and remove.
        --session.gc_probability (integer), session.gc_dvisor (integer )
            defined start probability gc (garbage collection) process at each session initiation, this probability is calculated by gc_probability / gc_divisor.
        
    6: About cookie:
        http cookie (also known as web cookie, or browser cookie) is sent to the user's browser and the server to save data in the browser, it will be launched once sent to carry on the server when requested in the browser.
        http cookie is an integral part of the http header.
        cookie What's the use?
            1: session state management (such as user login status, shopping cart)
            2: personalization settings (such as user-defined settings)
            3: track browser behavior (such as tracking user behavior analysis)
            
            
            

Guess you like

Origin blog.csdn.net/qq_41558265/article/details/94742482