Page 1 of 1
session problem
Posted: Wed Dec 24, 2003 2:32 am
by pelegk2
iam working ith code that i didnt write
but the thing i wan to ask
i get thing like session values that are still in "memory"!
how can i delete them?
i do :
$sess = session_start();
isnt it enough to delete the old session?
thanks in advance
peleg
Posted: Wed Dec 24, 2003 2:38 am
by Gen-ik
Start a Session : session_start() (don't know why your attaching it to a variable though)
Delete all variables from a Session : session_unset()
Destroy a Session : session_destroy()
Posted: Wed Dec 24, 2003 6:03 pm
by amarquis
You could also use
Code: Select all
<?php
session_unregister('FIELD1');
session_unregister('FIELD2');
?>
if you don't want to delete all variables and remove them manually...
Posted: Wed Dec 24, 2003 11:59 pm
by pelegk2
thanks all of u
can u redirect me to a very good step by step session article
Posted: Thu Dec 25, 2003 12:58 am
by volka
which version of php do you use? In case of doubt use the script at
viewtopic.php?t=8815#65245
It might be that session_unregister() is not what you should use.
http://php.net/session#session.examples shows you how to use session data with php versions 4.1 or above
this are the values i got :
Posted: Thu Dec 25, 2003 4:25 am
by pelegk2
PHP Version: 4.3.2
Display Errors: On
Error Level: E_ALL
Register Globals: On
Posted: Thu Dec 25, 2003 10:37 am
by Nay
Turn register_globals OFF! If it's your server then you can drop a .htaccess file to change it. Else if you wanted to have it on......then...nevermind that =/....
Anyhow, you can follow volka's second link. It'll have a few examples of the usage of sessions. Anyway, here's one from good ol spoono:
http://www.spoono.com/php/tutorials/tutorial.php?id=36
another one off of the monkey:
http://hotwired.lycos.com/webmonkey/00/ ... rogramming
Good luck,
-Nay
why do i need to put the register_globals off?
Posted: Sat Dec 27, 2003 11:46 pm
by pelegk2
i tried to use the file .htaccess
but it isnt working for me:(
Posted: Sun Dec 28, 2003 12:48 am
by Nay
What did you put in the .htaccess?
I hope it's not a blank file =\
-Nay
Posted: Sun Dec 28, 2003 5:41 am
by pelegk2
very funny
Posted: Sun Dec 28, 2003 10:45 am
by Gen-ik
To be honest you really shouldn't need to use .htaccess for this problem, and if you are not to sure about the .htaccess syntax then this will probably cause you more problems.
The best thing to do is to check out the PHP manual (try this... [php_man]session[/php_man]) because you can use sessions if you have register_globals on or off. The only difference is the way you read/write the session variables.
For example...
With register_globals turned on you can set a session variable simply using
$_SESSION["name"] = "bob" but with register_globals turned off you do
session_register("name"); $name = "bob"
Read the manual and all will be revealed
