How to Create a Session ID in PHP
- 1). Open a blank text document in any text editor.
- 2). Type the line:
<?php
to start the PHP script. - 3). Type:
session_start();
to start the session and create a unique ID for the session. - 4). Type:
if( session_id() == '' ){
to start the "if" statement that will check that the session ID has been created. - 5). Type the line:
echo 'No session ID!';
to print the line "No session ID!" if the session was not given an ID. - 6). Type the line:
}else{echo "The session ID is".session_id();}
to print the ID number that was given to the session. - 7). Type:
session_destroy();
to close the session and release the session ID. - 8). Type the closing tag:
?>
to end the PHP script. - 9). Save and close the file.
Source...