Weird ASP Session Issue
I have an ASP page which has this script at the top of the page:
Which means the page needs a value in the session variable "username" else it would redirect to the "notification.asp" page. This works perfectly when I click on hyperlinks that points to the above page. But if I click on a button instead of a hyperlink then the session does not work. Any idea why?
<% if session("username") = "" then
Code for Button:
<input type="button" value="Back To Home" OnClick="location.href='add-contact.asp';">
I don't see any reason why the session "does not work". What does the session variable become when using the location method?
Originally Posted by yamaharuss
it becomes empty
Have you tested that the session variable exists on the form page?
I think you need to double check that...
here's a successful test, feel free to recreate it..
<% session("username") = "Russ" %>
<input type="button" value="Back To Home" OnClick="location.href='b.asp';">
The above works fine.
<% Response.Write ("hello " &session("username")) %>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)