Noobs need to know bout session


#1

can someone explain how to use session in php…
and also… how to pass a session to the next page…
and my main problem is… what is session actually??
its already 4 days reading books…
but still i couldnt understand anything bout session… :cry:


#2

Well, you don’t exactly need to “Pass” sessions per se’, they are set (when you call for a session to be set) and an ID is assigned by the system. That ID is unique to that “Session” and Browser.

Sessions are very much like COOKIES but they are server side. After a PHP session is set, you can view the session id (and use it to manipuate things) by ) echoing the $_SERVER[‘PHPSESSID’] variable.

The session is stored (much like cookies) in a temporary location (such as /tmp) as a text file.

You really don’t need to do much to pass the info other than to pull it using the $_SESSION global array (http://us2.php.net/manual/en/language.variables.predefined.php) Also at the top of each page you want to use sessions just have the session_start() function.

I would also recommend reading up on http://us2.php.net/manual/en/function.session-start.php There are some basic examples there too, to help you out.

Also for clarification about sessions and cookies see evilcoder’s post at http://www.phphelp.com/forums/viewtopic.php?t=2736


#3

waahh… :D
tnx alot…
now i get the basic idea bout session and cookies…