The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ASP Programming
|
Clear session
Discuss Clear session in the ASP Programming forum on Dev Shed. Clear session ASP Programming forum discussing Active Server Pages coding techniques and problem solving methods. Use VBScript or Jscript to make dynamic web applications.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 8th, 2006, 04:52 AM
|
|
Contributing User
|
|
Join Date: Aug 2006
Posts: 558
  
Time spent in forums: 4 Days 23 h 13 m 27 sec
Reputation Power: 10
|
|
|
Clear session
Hi,
When I release session objects I do this
Code:
session("username")=""
So whats the difference when I do this
Code:
set session("username")=nothing
or
session.remove("username")
Isn't I already release it with a null value?
|

November 8th, 2006, 06:17 AM
|
|
|
|
There is a slight different between destroying a session and making it equal to nothing.
If it is equal to nothing then it does exist and use String or Len functions to compare/validate it.
Logically, if you destroy the session then is doesnot exist and you should be able to use IsNull or IsEmpty to compare/validate.
ASP VBScript is pretty lenient on some validation though.
http://www.w3schools.com/asp/met_abandon.asp
http://www.w3schools.com/asp/met_contents_remove.asp
|

November 8th, 2006, 04:27 PM
|
 |
Contributing User
|
|
Join Date: Nov 2004
Location: Sydney, Australia
Posts: 50
  
Time spent in forums: 6 Days 10 h 43 m 59 sec
Reputation Power: 11
|
|
If you want to "destroy" all of your session variables you can also use:
Hope this helps
Alex
|

November 14th, 2006, 08:29 PM
|
|
Contributing User
|
|
Join Date: Aug 2006
Posts: 558
  
Time spent in forums: 4 Days 23 h 13 m 27 sec
Reputation Power: 10
|
|
Hello,
I try to Stop IIS and when I Start it again sessions and application values are still there
How do you clear all this objects in IIS? can I clear it in using IIS?
|

November 14th, 2006, 11:37 PM
|
|
Registered User
|
|
Join Date: Oct 2006
Location: Bali - Indonesia
Posts: 28
Time spent in forums: 7 h 49 m 44 sec
Reputation Power: 0
|
|
hmm it sounds impossible dude when you restart IIS Then all user define variable will be released except cookies. it make a sense because those all variables exist under the IIS service.
release session,
if you using session("sesname") = "" mean
you assign the session to have empty string value but the session variable still exist in the service.
both set session("sesname")=nothing or session.remove("sesname") are quite same.
session.abandon mean you destroy all session variables in your current service
the best way to find out if the variables is exist or not by using isEmpty not isNull
try these code:
Code:
<%
' I never declare the session("1") but isNull will return false
Response.Write "isEmpty="&isEmpty(Session("1"))&"<br>"
Response.Write "isNull="&isNull(Session("1"))&"<br>"
%>
|

November 15th, 2006, 12:55 AM
|
|
Contributing User
|
|
Join Date: Aug 2006
Posts: 558
  
Time spent in forums: 4 Days 23 h 13 m 27 sec
Reputation Power: 10
|
|
|
Hi chazzuka,
Oh I thought IIS can clear those objects, I guess not. Thanks!
|

November 15th, 2006, 01:05 AM
|
|
Registered User
|
|
Join Date: Oct 2006
Location: Bali - Indonesia
Posts: 28
Time spent in forums: 7 h 49 m 44 sec
Reputation Power: 0
|
|
i mean when you stop the web service all the user define variables will be lost except cookies so i think it is impossible when u restart the IIS the the session still remain  or maybe cache problem
|

January 25th, 2007, 09:07 AM
|
|
Contributing User
|
|
Join Date: Aug 2006
Posts: 558
  
Time spent in forums: 4 Days 23 h 13 m 27 sec
Reputation Power: 10
|
|
Hello,
When I now use the clear session with a value set to nothing, I receive this error
error
Quote: Error Type:
Session object, ASP 0185 (0x80020003)
A default property was not found for the object.
/logout.asp, line 2 |
logout.asp
Code:
<%
session("id")=nothing
session("username")=nothing
session("islogin")=nothing
response.Redirect ("index.asp")
%>
|

January 25th, 2007, 09:12 AM
|
 |
Standing 3 feet to the left.
|
|
Join Date: Jan 2006
Location: USA
|
|
|
It's my understanding that you have to use "Set" when doing that, like "Set session("id") = Nothing". Give that a shot.
|

January 25th, 2007, 09:55 AM
|
|
Contributing User
|
|
Join Date: Aug 2006
Posts: 558
  
Time spent in forums: 4 Days 23 h 13 m 27 sec
Reputation Power: 10
|
|
Hi Tukaro,
I have Set it and when I redirect it to another page I receive this error
Quote: Error Type:
Response object, ASP 0185 (0x80020003)
A default property was not found for the object.
/index.asp |
because there is no line number to know where the error is, I think this is where it cause it
index.asp
Code:
.
.
.
<%if isempty(session("islogin")) then%>
.
.
.
what went wrong? 
|

January 25th, 2007, 10:13 AM
|
|
Contributing User
|
|
Join Date: Aug 2006
Posts: 558
  
Time spent in forums: 4 Days 23 h 13 m 27 sec
Reputation Power: 10
|
|
Hello,
After setting to nothing in LOGOUT.asp from the above code how come I couldn't use this condition?
Code:
<%if isempty(session("islogin")) then
response.write "is empty"
else
response.write "empty" <--won't show :(
end if
%>
|

February 14th, 2007, 06:46 AM
|
|
Registered User
|
|
Join Date: Feb 2007
Location: UK
Posts: 5
Time spent in forums: 2 h 51 m 42 sec
Reputation Power: 0
|
|
|
Have you tried:
Session("id") = Empty
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|