Friday, October 20, 2017

PHP Session Management With Some Tips

Long time back, we have discussed about the PHP Session for state management. Now I will share some new concepts about session that you might not heard about it. Check out our blog archive on the topic if you’re looking to learn about PHP Session For State Management.

Why do we need session ?

Sessions are a simple way to store data for individual users against a unique session ID. This can be used to persist state information between page requests.

Lets see the some more examples about PHP Session, Which may help you to build more understanding.

Generate Session ID using session_id() function.

Syntax :

string session_id ([ string $id ] )

session_id() is used to get or set the session id for the current session.

Example : 1[ Get the session ID]

Below code help you to generate the unique session ID for the current session and it will be the same throughout your browsing session.