Login e cookies
Salve a tutto il forum!
Il mio problema è connesso al sistema di login:
in pratica riesco a fare il login con il confronto dei dati presi da un DB, solo che poi ad un successivo rientro fell'utente vorrei che questo fosse riconosciuto come già loggato.Proprio per questo ho scritto dei cookies, ma non riesco ad ottenere il risultato sperato, in quanto il cookie viene scritto con i dati dell'utente ma mi rispunta la pagina di login.Dove sbaglio, forse dovrei fare una condizione di tipo IF THEN?
Pleaz, aiuto che ci sbatto su da tempo ormai...
Posto del codice:
LOGIN.ASP
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>ALIWORK POINT_SHOP</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <% Request.Cookies("log")("nick") Request.Cookies("log")("psw") nick = Request.Cookies("log")("nick") psw = Request.Cookies("log")("psw") %> <% if Request.Form("inviato") = "si" then Dim strnick, strpsw strnick = Trim(Replace(Request.Form("nick"), "'", "")) strpsw = Trim(Replace(Request.Form("psw"), "'", "")) if strnick <> "" AND strpsw <> "" then dim objConn, objRs, strSql set objConn = Server.CreateObject("ADODB.Connection") objConn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath("../../mdb-database/aliwork_shop.mdb") set objRs = Server.CreateObject("ADODB.RecordSet") strSql = "SELECT * FROM utenti WHERE nick='"& strnick &"' AND psw='"& strpsw &"';" objRs.open strSql, objConn, 1, 3 if not objRs.eof then Session("nick") = objRs("nick") Session("psw") = objRs("psw") %> <% else %> Login fallito. Nome utente e/o password sconosciuti. <% end if objRs.close objConn.close set objRs = nothing set objConn = nothing else %> I dati inseriti non sono corretti... riprovare. <% end if else %> <form name="login" action="login.asp" method="post"> Area riservata Nick: <input type="text" name="nick"> password: <input name="psw" type="password" id="psw"> <input type="hidden" name="inviato" value="si"> <input type="submit" value="Loggati"> <input type="hidden" name="data" value="<%=date()%>"15"> <input type="hidden" name="codhw" maxlength="50" size="25" value="<%=rec("codhw")%>"> <input type="hidden" name="cat" maxlength="50" size="25" value="<%=rec("cat")%>"> <input type="hidden" name="art" maxlength="50" size="25" value="<%=rec("art")%>"> <input type="hidden" name="descr" maxlength="50" size="25" value="<%=rec("descr")%>"> <input type="hidden" name="prz" maxlength="50" size="25" value="<%=rec("prz")%>"> <div align="left"> </div> <%end if%>
LOGIN_MAIN.ASP
codice:<html> <head> <body> <% Response.Cookies("log")("nick") = Request.Form("nick") Response.Cookies("log")("psw") = Request.Form("psw") Response.Cookies("log").Expires = Date + 2 %> <% dim scodhw dim sart dim scat dim sprz dim sdescr dim sdata scodhw=request.Form("codhw") scat=request.Form("cat") sart=request.Form("art") sdescr=request.Form("descr") sprz=request.Form("prz") sdata=request.Form("data") Session("ordine") = scodhw & "|" & scat & "|" & sart & "|" & sdescr & "|" & sprz& "|" & sdata & "|" %> </p> </p> </p> <link href="../file_asp/stile/stile.css" rel="stylesheet" type="text/css"></head> <body> <table border="1" align="left" cellpadding="2" cellspacing="2"> <tr> <td width="58" height="34" wcodth="112"> <div align="left">Codice</div></td> <td width="175" wcodth="102"> <div align="left">Categoria</div></td> <td width="53" wcodth="102">Articolo</td> <td width="78" wcodth="102">Descrizione</td> <td width="79" wcodth="102">Prezzo</td> </tr> <tr> <td height="36"> <div align="left"><font color="red"><%=scodhw%></font></div></td> <td> <div align="left"><font color="red"><%=scat%></font></div></td> <td><font color="red"><%=sart%></font></td> <td><font color="red"><%=sdescr%></font></td> <td><font color="red"><%=sprz%></font></td> </tr> <tr> <td height="25">QTA</td> <td colspan="4" rowspan="2"><form action="basket.asp" method="post" name="qta" target="_self" id="qta"> <p align="left"><font size="2"> </font> <input name="qta" type="text" id="qta" size="5" maxlength="3"> <input type="hidden" name="idcliente" id="idcliente" value="<%=rec("id")%>" size="25" maxlength="50"> <input type="hidden" name="email" id="email" value="<%=rec("email")%>" size="25" maxlength="50"> </p> <p align="left"><font size="2"> <input type="submit" name="Submit" value="Metti nel carrello"> </font></p> </FORM></td> </tr> <tr> <td height="17"> </td> </tr> </table> </p> </p> </p> </body> </head> </html>

Rispondi quotando
prova!
