Log in

View Full Version : Session Tutorial...



Rockonmetal
09-13-2007, 01:06 AM
I Know I've asked for this before... but I really am not in the mood for getting the shovel and digging through this forum to find it...

I was wondering if there were any really good tutorials on SESSIONS!
I would love to learn sessions cuz I've heard they make life easier...

Thanks!

Twey
09-13-2007, 01:12 AM
There's nothing really to tell about sessions. To use sessions, you have to call:
session_start(); at the top (very top, no HTML or whitespace before it or you'll get errors) of every page, then you can just read to and write from $_SESSION like any other associative array.

Yes, they are quite handy.

Rockonmetal
09-13-2007, 01:27 AM
So your saying I can do this:


$input = $_Session["Input"];
//Instead of doing this:
$input = $_POST["Input"];

If so that makes things easy
*And yes I know as long as I have session start at the top...*

Twey
09-13-2007, 01:31 AM
Yup, that's right. You can write to it too (you can write to $_GET and $_POST as well, it's just usually not very useful):
$_SESSION['myvar'] = 5;Then, on a completely separate page (with session_start() of course), you can just do:
do_something_with($_SESSION['myvar']);