0

I want to maintain the session into html pages but I have problem of finding a way to pass the session variables into html pages. So this is my login.asp code.

<%@Language="JavaScript"%>
<html>
<body>
<%

var Conn=Server.CreateObject("ADODB.Connection");
var DSN="DSN=file";
Conn.Open(DSN);

var Rst=Server.CreateObject("ADODB.Recordset");
var sql = "SELECT nme,userid,userpwd FROM student WHERE userid="+Request.Form("userid")+"AND userpwd='"+Request.Form("userpwd")+"'";
Rst.Open(sql,Conn);

if(!Rst.EOF)
{
    var user;
    Session("userid")=Rst("userid");
    Session("nme")=Rst("nme");
    Response.Write("Hi "+Session("nme")+"!. Welcome Back.Good to see you again. Redirect to homepage in 3 seconds");
    Response.Write("<br />");
    Response.Write("<a href='logout.asp'>Logout</a>");
    Response.AddHeader("REFRESH","3;URL=home.htm");
}   

else 
{


    Response.Redirect("login.htm");

}

%>
</body>
</html>
3
Contributors
2
Replies
13
Views
4 Years
Discussion Span
Last Post by hometownnerd
0

When redirecting, you need to redirect to other .asp pages. You cannot access the session variable(s) in .htm pages. You should be building .asp pages within your web application so that you can include server side scripting in those pages to access the session variable(s).

0

What about adding the session stuff into a cookie or two and then retrieving the cookies with javascript inside of the htm pages? That could work. Just a thought.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.