L?I: Set-Cookie b? qua trong CGI khi k?t h?p v?i v? tr

D?ch tiu ? D?ch tiu ?
ID c?a bi: 176113 - Xem s?n ph?m m bi ny p d?ng vo.
Chng ti ? ngh? t?t c? ng?i dng nng c?p ? Microsoft Internet Information Services (IIS) Phin b?n 7.0 ch?y trn Microsoft Windows Server 2008. IIS 7.0 lm tng ng k? Web an ninh c s? h? t?ng. ? bi?t thm chi ti?t v? cc ch? ? lin quan ?n an ninh IIS, gh thm Web site sau c?a Microsoft:
http://www.Microsoft.com/technet/Security/prodtech/IIS.mspx
? bi?t thm chi ti?t v? IIS 7.0, gh thm Web site sau c?a Microsoft:
http://www.iis.net/default.aspx?tabid=1
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TRI?U CH?NG

Khi m?t ?ng d?ng CGI s? g?i m?t tiu ? Set-Cookie v?i "302 Object Moved" ph?n ?ng v v? tr tiu ?, Internet Information Server (IIS) b? qua cc ?u ? cookie.

GI?I PHP

Hnh vi ny l vi ph?m c?a ?c t? CGI, ti?u bang, "b?t k? tiu ? m khng ph?i l h? ph?c v? ch? th? ?c g?i tr?c ti?p v? cc khch hng. Hi?n nay, ?c t? ny ?nh ngh?a ba my ch? ch? th?..."

Nh l m?t workaround, h?y ch?c ch?n r?ng tn t?p tin EXE b?t ?u v?i "nph-" v t? t?o ra t?t c? cc tiu ? HTTP trong chng tr?nh c?a b?n. "nph-" ch? ra v?i cc h? ph?c v? chng tr?nh CGI l ? ch?y trong ch? ? tiu ? khng phn tch. CGI c hai ch? ?. Trong ch? ? chu?n (phn tch thng tin th), b?n ph?i g?i m?t trong nh?ng CGI ch? th? ? s?n l?ng tiu chu?n (Content-type, ?a i?m ho?c t?nh tr?ng). CGI ?nh d?ng m?t HTTP h?p l? ph?n ?ng ?ng d?a trn ch? th? b?n g?i. N ?nh d?ng cc tiu ? HTTP tiu chu?n cho b?n, v n nn bao g?m b?t k? cc tiu ? m b?n ? ch? ?nh.

Cc ch? ? khc l ch? ? tiu ? khng phn tch. Trong ch? ? ny CGI khng ?t b?t k? tiu ? chnh n. Chng tr?nh CGI ph?i ?nh d?ng m?t h?i p HTTP ?y ? bao g?m ph?n ?ng dy v t?t c? ?u th. Cc my ch? s? khng thm ho?c s?a ?i b?t k? tiu ? cho b?n trong ch? ? ny.

Cng ?c l m?t chng tr?nh CGI c tn b?t ?u b?ng "nph-" ch?y trong ch? ? tiu ? khng phn tch; N?u khng, cc chng tr?nh CGI ?c i?u hnh trong tiu ? phn tch ch? ?.

T?NH TR?NG

Microsoft ? xc nh?n i?u ny l m?t l?i trong cc s?n ph?m c?a Microsoft ?c li?t k ?u bi vi?t ny.

THNG TIN THM

Cc b?c ? t?o l?i hnh vi

Bin d?ch chng tr?nh CGI ny nh l m?t ?ng d?ng giao di?n i?u khi?n Win32 v ?t n trong m?t th m?c trn my ch? IIS c?a b?n ni m n c th? ?c th?c hi?n:
#include <stdio.h>
int main()
{
  printf("Location: %s\r\n", "http://www.yahoo.com");
  printf("Set-Cookie: Name1=Value1; path=/;
    expires=Fri, 22 May 1998 21:00:00 GMT\r\n\r\n");
  return 0;
}
				

G?i cho chng tr?nh CGI t? tr?nh duy?t c?a b?n v quan st ?u ra c?a n (thng qua m?ng Mn h?nh, v d?). N s? ?c tng t? nh ny:
HTTP/1.0 302 Object moved
Location: http://www.yahoo.com
Server: Microsoft-IIS/2.0
Content-Type: text/html
Content-Length: 145

<head><title>Document moved</title></head>
<body><h1>Object Moved</h1>This document may be found
<a HREF="http://www.yahoo.com">here</a></body>
				

Lu ? r?ng cc tiu ? Set-Cookie ? khng ?c g?i b?i IIS. N?u b?n c c?nh bo cookie b?t ln trong tr?nh duy?t c?a b?n, khng c c?nh bo xu?t hi?n.

? cho php m?t cookie ?c thi?t l?p trong m?t ph?n ?ng 302, s? d?ng m? tng t? nh cc sau y, v ti?n t? "nph-" ? tn t?p tin th?c thi:
#include <stdio.h>
int main()
{
  printf("HTTP/1.0 302 Redirect\r\n");
  printf("Location: %s\r\n", "http://www.yahoo.com");
  printf("Set-Cookie: Name=Value; path=/; expires=Fri, 22 May 1998 21:00:00
   GMT\r\n\r\n");
  return 0;
}
				

?u ra l tng t? nh sau. Lu ? r?ng cookie by gi? g?i, v khng c tiu ? ?c b? sung b?i cc my ch?.
HTTP/1.0 302 Redirect
Location: http://www.yahoo.com
Set-Cookie: Name=Value; path=/; expires=Fri, 22 May 1998 21:00:00 GMT
				

THAM KH?O

(c) t?p on Microsoft 1997, t?t c? cc quy?n. Nh?ng ng gp c?a Leon Braginski, t?p on Microsoft

Thu?c tnh

ID c?a bi: 176113 - L?n xem xt sau cng: 19 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Internet Information Server 3.0
  • Microsoft Internet Information Services 5.0
T? kha:
kbbug kbnofix kbmt KB176113 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:176113

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com