Forum Moderators: open

Message Too Old, No Replies

expiring a variable

how to expire a variable after passing it

         

Ecstacy

8:04 am on Mar 1, 2003 (gmt 0)

10+ Year Member



I am generating a password and including it in a variable.

Now what i want to do is to destroy the value of the variable containing password.

How can i do that?

hakre

8:48 am on Mar 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi Ecstacy,

don't know if this answers your question correctly, but you can set the value of the variable to a zero-length string for example.

$sPass = ""

does this makes sense?

Ecstacy

9:33 am on Mar 1, 2003 (gmt 0)

10+ Year Member



thanks for your reply,

but i have already tried it but isn't working.

And yes I am working on asp not php.

hakre

9:56 am on Mar 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi ecstacy,

try to unset the variable. this will indeed detroy it. if it's not cookie related or a server variable. please check, ie make a debug output to display the var after you set it to a zero length string to check wether this was successfull or not.

in vb there is no explicit command to unset a variable. maybe you can use the redim command to do so.

txbakers

5:44 pm on Mar 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can set it to null, which effectively destroys it:

set myvar = null ( in VB)

You should destroy all of your non-data objects as well in ASP becuase they can suck of memory if left assigned.

Any DB connections, SQL statements, ADODB objects, etc. all should be nullified when you are finished with them. ASP doesn't have a very efficient garbage collection mechanism.

hakre

7:18 pm on Mar 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi txbakers,

setting a var to null does not destroy it, isn't it. you'll even create a variable of the object type which will catch up more memory than an emptry string, so this isn't saving any memory at all. or have i programmed to much php lately ;)?

txbakers

11:27 pm on Mar 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I always thought it did.

Or is it:

set myvar = nothing

that destroys it.

yes, myvar = null is the javaScript way.