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>

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).

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.