#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Retrieving cookies


    Hello, im new to programming. Im making a login program that will go check ms access and then direct them to specific pages. Now my problem is to display the contents of the int213userid cookie in the Employee ID text box the first time the page is loaded and If they fail to log in for any reason, keep the value of the Employee ID text box in the text box for their next attempt.

    coding =
    Code:
    Dim empid, password, errormsg, checker, sameid  
    
    sameid = request.Cookies("int213userid") 
    checker = 0  	
    
    Do While Not Objrs.EOF  
    If lcase(Request("empidfield")) = lcase(Objrs("empid")) AND Request("emppwfield") = Objrs("Password") Then  		
    
    Session ("UserloggedIn") = "empidfield" 		 		
    if Objrs("admin") = true then 			
    if request("remember") = true then 			
    'put cookie into int213userid 		
    
    response.cookies("int213userid")=request("empidfield") 
    
    response.cookies("int213userid").Expires = date + 30 			
    Response.Cookies("int213userid") = sameid 			
    'Call Response.Redirect("menu.asp") 
    		else  			
    'Call Response.Redirect("menu.asp")  			
    end if 			 		
    End If 		 		
    if Objrs("admin") = false then  	
    		
    if request("remember") = true then 			
    
    response.cookies("int213userid")=request("empidfield") 
    
    response.cookies("int213userid").Expires = date +
    30 			
    Response.Cookies("int213userid") = sameid 			
    'Call Response.Redirect("Payroll-entry.asp") 			
    
    else  		
    	
    'Call Response.Redirect("Payroll-entry.asp") 			
    end if 		
    end if 		 
    else  		
    Session ("UserloggedIn") = "" 		
    errormsg= "error" 		
    checker = 1  
    End If  
    Objrs.MoveNext loop 	
    Objrs.close 	
    set Objrs = nothing 	
    Objconn.close 	
    set Objconn = nothing
    HTML =
    Code:
    <form method="post" name="login" action="" >   
    <p align="center">Employee ID:&nbsp;&nbsp;&nbsp;    
    <input name="empidfield" type="text" size="20" value="<%=sameid%>"/> 
    </p>    
    <p align="center">Password:  
    <input name="emppwfield" type="text" size="20" /> 
    </p>   
    <p align="center"><input checked="checked" name="remember" value="checkit" type="checkbox" />Remember Employee ID<br />   </p>   
    <p align="center"> <input name="button" id="button" value="Login" type="submit" /> </p>   
    <p align="center"><font color="red">
    i am trying different stuff but none of them are working. Please Help! Asking for help was my last resort before i pull my hair. Thank You!
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,439
    Rep Power
    4539
    What exactly doesn't work? What exact code are you working with? What have you done to debug your problem, do you get any error messages?
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0
    At the moment, there are no errors. whats not working is my variable 'sameid' which gets the information from the cookie int123userid and should leave the name in the text box.

    sameid = request.Cookies("int213userid")

    <input name="empidfield" type="text" size="20" value="<%=sameid%>"/>

IMN logo majestic logo threadwatch logo seochat tools logo