Log in

View Full Version : PHP session generator



tech_support
06-23-2006, 10:11 AM
Hi all,

I'm looking for a script that generates a session ID; saves the information on that id (using cookies perhaps); and if the user "accidently" clicks refresh the information will still be there. They could type in there session id and it'll be restored instantly.

And even if they close their browser the information will still be there.

And when they're finished, they click "Logout" or something like that and it logs their information and then closes. Then when you start it again (different user) it starts again.

This is for alot of people and i don't want them to have the same info as others :)

I'd appreciate it if there's one or you can make one.

If you can do it, thanks. If you can't do it, thanks anyway ;)

PS: No experience in PHP so please bear with me please :)

Twey
06-23-2006, 12:59 PM
Sessions are very easy to use in PHP.
<?php
session_start();
$_SESSION['your_var'] = "your value";
?>
<!-- ... stuff ... -->
<?php
$my_var = $_SESSION['your_var'];
?>

tech_support
06-24-2006, 03:30 AM
Does that save the info on forms using cookies or something else?

Twey
06-24-2006, 06:01 AM
No, it uses sessions. :)

tech_support
06-24-2006, 06:03 AM
Cool. Can you show me how to use it? :) Please!

Me stupid.

Twey
06-24-2006, 06:05 AM
Lol, well, $_SESSION is an array that only exists after calling session_start(). You can put anything you like into that array, and it'll be available to any other page that calls session_start() until the session expires.

tech_support
06-24-2006, 06:06 AM
OK. How do you end the session then?

tech_support
06-24-2006, 06:07 AM
And can you give me a tutorial link on sessions?

Twey
06-24-2006, 06:59 AM
You can end the session by calling session_destroy(), or if the browser cannot pass the session ID to the next page, either via cookies or appending it to URLs as a GET variable.

http://www.google.com/search?q=php+session+tutorial

tech_support
06-24-2006, 07:01 AM
thanks