Aleks
asked on
ASP/JS Classic page, create session error
I have the following code that is used to filter out a recordset based on values from a form.
I need to add code to create a session value based on the returned value from one of the fields.
--- code----
<%
// *** Validate request to log in to this site.
var MM_LoginAction = Request.ServerVariables("U RL");
if (Request.QueryString!="") MM_LoginAction += "?" + Server.HTMLEncode(Request. QueryStrin g);
var MM_valUsername=String(Requ est.Form(" username") );
if (MM_valUsername != "undefined") {
var MM_fldUserAuthorization="" ;
var MM_redirectLoginSuccess="f orgotpassw ordsent.as p";
var MM_redirectLoginFailed="fo rgotpasswo rdnotfound .asp";
var MM_flag="ADODB.Recordset";
var MM_rsUser = Server.CreateObject(MM_fla g);
MM_rsUser.ActiveConnection = MM_CMS2003_STRING;
MM_rsUser.Source = "SELECT Loginid, Email";
if (MM_fldUserAuthorization != "") MM_rsUser.Source += "," + MM_fldUserAuthorization;
MM_rsUser.Source += " FROM dbo.vuEmailreset WHERE Loginid='" + MM_valUsername.replace(/'/ g, "''") + "' AND Email='" + String(Request.Form("Email ")).replac e(/'/g, "''") + "'";
MM_rsUser.CursorType = 0;
MM_rsUser.CursorLocation = 2;
MM_rsUser.LockType = 3;
MM_rsUser.Open();
if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match - this is a valid user
Session("MM_Username") = MM_valUsername;
if (MM_fldUserAuthorization != "") {
Session("MM_UserAuthorizat ion") = String(MM_rsUser.Fields.It em(MM_fldU serAuthori zation).Va lue);
} else {
Session("MM_UserAuthorizat ion") = "";
}
if (String(Request.QueryStrin g("accessd enied")) != "undefined" && false) {
MM_redirectLoginSuccess = Request.QueryString("acces sdenied");
}
MM_rsUser.Close();
Response.Redirect(MM_redir ectLoginSu ccess);
}
MM_rsUser.Close();
Response.Redirect(MM_redir ectLoginFa iled);
}
%>
----
The session variable I need to add is:
Session ("userloginid")=(EmployeeL ogin.Field s.Item("us erloginId" ).Value)
---
I am just not sure where to add that code.
I need to add code to create a session value based on the returned value from one of the fields.
--- code----
<%
// *** Validate request to log in to this site.
var MM_LoginAction = Request.ServerVariables("U
if (Request.QueryString!="") MM_LoginAction += "?" + Server.HTMLEncode(Request.
var MM_valUsername=String(Requ
if (MM_valUsername != "undefined") {
var MM_fldUserAuthorization=""
var MM_redirectLoginSuccess="f
var MM_redirectLoginFailed="fo
var MM_flag="ADODB.Recordset";
var MM_rsUser = Server.CreateObject(MM_fla
MM_rsUser.ActiveConnection
MM_rsUser.Source = "SELECT Loginid, Email";
if (MM_fldUserAuthorization != "") MM_rsUser.Source += "," + MM_fldUserAuthorization;
MM_rsUser.Source += " FROM dbo.vuEmailreset WHERE Loginid='" + MM_valUsername.replace(/'/
MM_rsUser.CursorType = 0;
MM_rsUser.CursorLocation = 2;
MM_rsUser.LockType = 3;
MM_rsUser.Open();
if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match - this is a valid user
Session("MM_Username") = MM_valUsername;
if (MM_fldUserAuthorization != "") {
Session("MM_UserAuthorizat
} else {
Session("MM_UserAuthorizat
}
if (String(Request.QueryStrin
MM_redirectLoginSuccess = Request.QueryString("acces
}
MM_rsUser.Close();
Response.Redirect(MM_redir
}
MM_rsUser.Close();
Response.Redirect(MM_redir
}
%>
----
The session variable I need to add is:
Session ("userloginid")=(EmployeeL
---
I am just not sure where to add that code.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If I do this:
MM_rsUser.Open();
if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match - this is a valid user
Session("MM_Username") = MM_valUsername;
Session ("reqloginid")=(EmployeeLo gin.Fields .Item("Use rLoginId") .Value)
if (MM_fldUserAuthorization != "") {
Session("MM_UserAuthorizat ion") = String(MM_rsUser.Fields.It em(MM_fldU serAuthori zation).Va lue);
} else {
Session("MM_UserAuthorizat ion") = "";
}
I get this error:
Microsoft JScript runtime error '800a138f'
'EmployeeLogin.Fields' is null or not an object
/bluedot/forgotpassword.as p, line 29
MM_rsUser.Open();
if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match - this is a valid user
Session("MM_Username") = MM_valUsername;
Session ("reqloginid")=(EmployeeLo
if (MM_fldUserAuthorization != "") {
Session("MM_UserAuthorizat
} else {
Session("MM_UserAuthorizat
}
I get this error:
Microsoft JScript runtime error '800a138f'
'EmployeeLogin.Fields' is null or not an object
/bluedot/forgotpassword.as
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Without this line:
Session ("reqloginid")=(EmployeeLo gin.Fields .Item("Use rLoginId") .Value)
It succeeds and moves to the next page but I get no ID from the record that was filtered, which is what I need.
Session ("reqloginid")=(EmployeeLo
It succeeds and moves to the next page but I get no ID from the record that was filtered, which is what I need.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all !
ASKER
I tried adding this below, like this:
if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match - this is a valid user
Session("MM_Username") = MM_valUsername;
Session ("reqloginid")=Request.For
On the next page I try to retrieve the session value, but doesn't display anything. Even tho the check was successful and a record was found.
I have: Session: <%=Session("reqloginid")%>
Displays nothing.
If I try to add your code I get: An intrinsic object cannot be stored within the Session object.
// username and password match - this is a valid user
Session("MM_Username") = MM_valUsername;
Session ("reqloginid")=Request.For