Link to home
Start Free TrialLog in
Avatar of designersx
designersx

asked on

how to make logout in asp?

how to expire/destroy session in asp?

can u please tell me the code of logout ?
Avatar of JoachimMartinsen
JoachimMartinsen
Flag of Norway image

¨
session("youreSessionNameForLoggedIn") = false
 
OR
 
session("youreSessionNameForLoggedIn") = ""

Open in new window

Avatar of Ryan Chong
logout usually means destroy all session variables, so try use command:

Session.Abadon

instead.
typo..

should be:

Session.Abandon
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of its_parikshit
its_parikshit

try


session=nothing

if session.Abandon doesn't work


'try 
 
session=Nothing
 
 
'if session.abandon doesn't work

Open in new window

There are two types of sessions logouts - 1 which kills your user session, and one which killes your variables. The below code if inserted into your web config will destroy both and redirect the user to the login page:

<system.web>
       <sessionState timeout="20" mode="InProc"/>
       <authentication mode="Forms">
      <forms loginUrl="UserLogin.aspx" defaultUrl="~/Default.aspx" name=".ASPXFORMSAUTH" enableCrossAppRedirects="true" protection="All" path="/" timeout="20"/>
        </authentication>
</system.web>


This will end both sessions types ie 20, and direct users to the login page. You could also wire up the login control which would handle the pain of logging in and will use this config to automatically handle user sessions and logout procedures.

Let me know if this helps