Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Guilherme Teixeira

Cookies - Na hora de login

Recommended Posts

Olá amigos,

 

estou com o seguinte problema, tenho uma tabela que se chama 'usarios', ela possui os seguintes campos:

 

Id_usuario (auto numeração)

Nome:

Login:

Senha:

 

o código da pagina de login é o seguinte:

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/Medio.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("login"))
If MM_valUsername <> "" Then
  MM_fldUserAuthorization="Nivel"
  MM_redirectLoginSuccess="boletim_index.asp"
  MM_redirectLoginFailed="error_boletim.asp"
  MM_flag="ADODB.Recordset"
  set MM_rsUser = Server.CreateObject(MM_flag)
  MM_rsUser.ActiveConnection = MM_Medio_STRING
  MM_rsUser.Source = "SELECT Login, Senha"
  If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  MM_rsUser.Source = MM_rsUser.Source & " FROM Usuarios WHERE Login='" & Replace(MM_valUsername,"'","''") &"' AND Senha='" & Replace(Request.Form("senha"),"'","''") & "'"
  MM_rsUser.CursorType = 0
  MM_rsUser.CursorLocation = 2
  MM_rsUser.LockType = 3
  MM_rsUser.Open
  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then 
	' username and password match - this is a valid user
	Session("MM_Username") = MM_valUsername
	If (MM_fldUserAuthorization <> "") Then
	  Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
	Else
	  Session("MM_UserAuthorization") = ""
	End If
	if CStr(Request.QueryString("accessdenied")) <> "" And false Then
	  MM_redirectLoginSuccess = Request.QueryString("accessdenied")
	End If
	MM_rsUser.Close
	Response.Redirect(MM_redirectLoginSuccess)	
   	End If
  MM_rsUser.Close
  Response.Redirect(MM_redirectLoginFailed)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<%=MM_LoginAction%>">
  <table border="0">
	<tr>
	  <td>Login:</td>
	  <td><label>
		<input name="login" type="text" id="login" />
	  </label></td>
	</tr>
	<tr>
	  <td>Senha:</td>
	  <td><label>
		<input name="senha" type="password" id="senha" />
	  </label></td>
	</tr>
  </table>
  <label>
  <input name="Submit" type="submit" id="Submit" value="Acessar" />
  </label>
</form>
</body>
</html>

Gostaria de saber como eu faria para que na hora que efetuasse o login, criasse um Cookie com o valor de ID_aluno.

 

Muito Obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

Aqui mostra como fazer praticamente todas operações com cookies

 

http://pt.wikipedia.org/wiki/Cookie

 

Logo em baixo tem a aprte de ASP

 

Basicamente é

 

response.Cookie("nomedocookie") = "valor"

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.