Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem session_unregister

Status
Not open for further replies.

Artur

Programmer
Mar 28, 2001
11
0
0
PT
whem i use the function session_unregister to clean a variable from my session, if in the same session i do a session register to the sam variable, the variable contains the the last value, and i don't want that, and it should not happen.

example :

session_register("a")
$a = 1
session_unregister("a")

.....



session_register("a")

-- and know the variable contains "1" and it should be empty

Artur Carvalho
ajc@mni.pt
Portugal
 
Try using [tt]session_destroy()[/tt]. That destroy's all session data.

Hope this helps,
-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
I don´t want to destroy the session, because i have other variables that i don't want to lose. I can build a function that it destroy the session, and immediatly it start a new session width all the variables that i want.

Other solution is to reset the variables .

But i think that it should be another way

Artur Carvalho
ajc@mni.pt
Portugal
 
try unset($your_var) whihc will destry that var in the session data
 
I would try using the unset() function prior to using the session_unregister.

Bill
 
remember that even though you have called session_unregister("a"), your variable still exists ($a = 1).

Also, as good practice, you should set your variable then call session_register.

$a = 1;
session_register("a");

then you can call do

unset($a);
session_unregister("a");

also keep in mind that the unset($a) is only required if you set a variable, register a session var and then want to kill the variable all within the same instance of script execution. If you set the variable and register it, you wont need to use unset($a) because the scalar variable of $a no longer exists in its hard form (only exists in the session).

I hope I did not confuse you here. Sorry if I did.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top