Log in

View Full Version : Session help ...



pcbrainbuster
03-09-2007, 04:31 PM
Hello :),

I really think the using the session thingy to sort of track the user is pretty cool so what I need to know is how to use session ...

Thanks :)

thetestingsite
03-09-2007, 04:33 PM
Take a look at the tutorials on PHP.net (http://us2.php.net/manual/en/ref.session.php)

These have all of the functions that you need to know to use sessions.

Hope this helps.

pcbrainbuster
03-09-2007, 04:36 PM
Thanks thetestingsite - i will be reading the page for some time :)

pcbrainbuster
03-11-2007, 06:50 PM
Ok I have completely lost it ! - i can not understand... can anyone here please give me begginer to advanced explanation here ?

Thanks :)

Twey
03-11-2007, 07:46 PM
Basically, you can use $_SESSION just like any other array, so long as you session_start() on each page before sending any data.

pcbrainbuster
03-11-2007, 10:28 PM
Please remember i am a stupid begginer and need more than that :)

Twey
03-11-2007, 11:01 PM
That was the short answer. The long answer is the link that thetestingsite posted :)

tech_support
03-12-2007, 06:37 AM
session_start();
Starts the session.

session_destroy();
Closes the session

$_SESSION['name'] = 'value';
Writes "value" into "name"

$data = $_SESSION['name'];
Retrieves the value of "name"

session_regenerate_id();
Changes the session ID

session_id();
Gets the session ID

unset($_SESSION['name']);
Deletes the value of 'name'

pcbrainbuster
03-12-2007, 07:50 AM
Thanks for your posts :), may i have an example ?

pcbrainbuster
03-12-2007, 04:40 PM
Pleeeeeeeease :)

tech_support
03-14-2007, 05:19 AM
Pleeeeeeeease :)

I can see why you have 298 posts :rolleyes:

Here's one example:

index.php


<?php

session_start(); //Starts the session
$_SESSION['hello'] = 'Hello! This is "saved" session data. :)';
//Writes the value of "hello" to the session file.

?>

somepage.php


<?php
session_start(); //Starts the session
echo $_SESSION['hello']; //Writes the data of 'hello'
?>


:)