Session on PHP Language

In Code on 6:22 am

Well, this time I’ll write you about Session.. yah.. a real concept which i think the most important thing at the CGI programming when we are talking about the security aspects.
Now lets start..
Session analogical are like a account we assign into a server. The simple way to understad it is by the real example.. Im sure you ever login into any sites related into user support and connect to a database, right ?
well, whenever you login in, the real are you are assign a information about your account informations, including user id, even your password, but some mecines will encrypt this, dont be worry..:)
This information will be saved in a specified server untill you sign out (log out). When you decide to log out, the system will kill your session in server so you dont have any account anymore..
Now, lets practice this mecanism.. :)

<?php
session_start(); // start session
$_SESSION['name'] = ‘betet’;
?>

remember… you have to write session_start(); to enable the session. This function not only used to start the session but also to continue the session assigned before.. so that you can use your session information in whole scripts and pages.
The real conditions are, you have wrote or assign your information ($_SESSION['name'] = ‘betet’;).. session name (betet) will be saved into server to assign your identity.

Now, how to kill my session information ?
check this scripts..

<?php
session_start();
session_destroy();
?>

This script will destroy your session file from the server and of course you will not known anymore.
so if you want to save your information again you have to login again..

well, i think thats enough.. for further information please drop me a reply…

Regards

Andika Kurniantoro,
Blogger paruh waktu. Karyawan di sebuah perusahaan swasta Indonesia. Lajang. Gemar menonton film dan membaca buku sejarah.

Related posts ...

    It is your turn now!