This topic is locked

clearing Session Variables

2/10/2007 8:25:33 AM
PHPRunner General questions
T
thesofa author

Hi

If I use a session variable of $_SESSION["owner"] in one event in one area of my application, then at a later point of the application, the value in the field `owner` changes and the value of $_SESSION["owner"] needs to change too, do I need to set the value of $_SESSION["owner"] to "" when I have finished using it with the value the first time?

e.g.

do thing 1

set $_SESSION["owner"]="wertyuioplkj"

use $_SESSION["owner"]

finish doing thing 1

do thing 2

set $_SESSION["owner"]="sdfghj"

use $_SESSION["owner"]

finish doing thing 2


would be the program flow,

should I set the value of $_SESSION["owner"] to "" after each use?

will it help free up memory?

I remember having to free variables in some lingo I learnt last century, is it good practise to do it in PHP?

I was wondering if it could lead to data corruption where $_SESSION["owner"] is changed frequently in a programme?

Sorry for being so thick on this one <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=4602&image=1&table=forumtopics' class='bbc_emoticon' alt=':D' />

cheers

Alexey admin 2/12/2007

Hi,
you wrote:

I remember having to free variables in some lingo I learnt last century, is it good practise to do it in PHP?


You shouldn't care about unused variables until their number is less than several hundreds.

Otherwise use unset function to free them.

T
thesofa author 2/12/2007

Hi,

you wrote:
You shouldn't care about unused variables until their number is less than several hundreds.

Otherwise use unset function to free them.



Did you mean More than several hundreds?

Thanks for the reply.