{"id":1969,"date":"2012-03-29T11:17:24","date_gmt":"2012-03-29T15:17:24","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=1969"},"modified":"2012-03-30T15:13:20","modified_gmt":"2012-03-30T19:13:20","slug":"vb-net-end-user-session","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2012\/03\/vb-net-end-user-session\/","title":{"rendered":"VB.NET &#8211; End user session"},"content":{"rendered":"<p>To end user session and disable user from using a back button to go back to secure page, you need two pages i simply named killsession.aspx and logout.aspx. I will explain both pages with code behind and markup code.<\/p>\n<p><strong>killsession.aspx<\/strong><\/p>\n<blockquote><p>\nkillsession.aspx (markup code)<\/p>\n<pre>\r\n<code>\r\n&lt; !DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \r\n      \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\r\n\r\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\r\n&lt;head runat=\"server\">\r\n    &lt;title>\r\n&lt;\/head>\r\n&lt;body>\r\n    &lt;form id=\"form1\" runat=\"server\">\r\n    &lt;div>\r\n    &lt;div>\r\n    &lt;\/form>\r\n&lt;\/body>\r\n&lt;\/html>\r\n<\/code>\r\n<\/pre>\n<p>killsession.aspx.vb (code behind)<\/p>\n<pre>\r\n<code>\r\nPartial Class Close_Session\r\n  Inherits System.Web.UI.Page\r\n  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) \r\n                          Handles Me.Load\r\n      Session.Clear()\r\n      Session.Abandon()\r\n      Session.Remove(\"Name\")\r\n\r\n      Response.Redirect(\"logout.aspx\")\r\n\r\n    End Sub\r\nEnd Class\r\n<\/code>\r\n<\/pre>\n<\/blockquote>\n<p><strong>logout.aspx<\/strong><\/p>\n<blockquote>\n<pre>\r\nlogout.aspx (markup code)\r\n<code>\r\n&lt;%@ Page Language=\"VB\" AutoEventWireup=\"false\" \r\nCodeFile=\"logout.aspx.vb\" Inherits=\"logout\" %>\r\n\r\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \r\n\"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\r\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\r\n&lt;head runat=\"server\">\r\n    &lt;title>\r\n    &lt;script language=\"javascript\">\r\n    \/\/disable user from going back \/\/\r\n        function doLogout() {\r\n            history.go(+1)\r\n        }\r\n        &lt;\/script>\r\n&lt;\/head>\r\n&lt;body>\r\n    &lt;form id=\"form1\" runat=\"server\">\r\n    &lt;div>\r\n    &lt;\/div>\r\n    &lt;\/form>\r\n&lt;\/body>\r\n&lt;\/html>\r\n<\/code>\r\n<\/pre>\n<pre>\r\nlogout.aspx.vb (code behind)\r\n<code>\r\nPartial Class logout\r\n  Inherits System.Web.UI.Page\r\n  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) \r\n                       Handles Me.Load\r\n       'fire-up java code from a markup page\r\n        If (Not ClientScript.IsStartupScriptRegistered(\"doLogout\")) Then\r\n            Page.ClientScript.RegisterStartupScript _\r\n            (Me.GetType(), \"history\", \"doLogout();\", True)\r\n        End If\r\n        'redirect user to a page of your choice\r\n         Response.Redirect(\"default.aspx\")  \r\n    End Sub\r\nEnd Class\r\n<\/code>\r\n<\/pre>\n<\/blockquote>\n<p>Related posts:<br \/>\n<a href=\"http:\/\/www.iowawebnet.com\/ein\/2011\/02\/ending-user-session\/\">Disable Back Button<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To end user session and disable user from using a back button to go back to secure page, you need two pages i simply named killsession.aspx and logout.aspx. I will explain both pages with code behind and markup code. killsession.aspx killsession.aspx (markup code) &lt; !DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;> &lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221;> &lt;head [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,17,16,43,84],"tags":[92,37,94,38,64,93],"class_list":["post-1969","post","type-post","status-publish","format-standard","hentry","category-net-4-0","category-applications","category-net","category-javascript-2","category-vs2010","tag-end","tag-javascript","tag-secuirty","tag-security","tag-session","tag-user"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1969"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=1969"}],"version-history":[{"count":20,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1969\/revisions"}],"predecessor-version":[{"id":2025,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/1969\/revisions\/2025"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=1969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=1969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=1969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}