Set-Cookie does not work

M

marcwentink

I am using socket programming and I am sending a request from client to
server, I have made this message in my program but somehow, the COOKIE
I set does not get to the server:

This is my message:

POST /cgi-bin/xxxxxx/xxxxxxxxxxxxx HTTP/1.1
Accept: */*
Referer: http://xxxxxxxxx.xxx.xxxxx:80/cgi-bin/xxxxxx/xxxxxxxxxxxxx
Content-Type: application/x-www-form-urlencoded
Content-Length: 15
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: xxxxxxxxx.xxx.xxxxx:80
Connection: Keep-Alive
Cache-Control: no-cache
Set-Cookie: SessieString=xxxxxxxxxxxxxxxx;
path=/cgi-bin/xxxxxx/xxxxxxxxxxxxx; v
ersion=1

action=xxxxxxxx

I did got some info, the parameter 'action' is read correctly at the
server side, but getting some debug info tells me that no Cookies are
present, at all, at the Server Side. Let alone the named Cookie
SessieString.

I feel, to put it diplomaticly, 'somewhat frustrated', trying all kinds
of things, and not knowing what I do wrong. I 've been prutsing with it
the whole day now...

I tried Cookie instead of Set Cookie, with and without the path en
version, and the letter with and without the semicolon. I used /r/n
since the server is on unix (Apache) and I am sending from a
windows-client (Little C program written in g++).

:-(

Please help me!
 
D

David Dorward

I am using socket programming and I am sending a request from client to
server, I have made this message in my program but somehow, the COOKIE
I set does not get to the server

The browser makes a request, which includes any cookies that are set
already.

The server makes a response, which can set cookies.

Are you trying to read the cookies inside the script that just set them? If
so they won't exist yet.
 
M

Michael Winter

On 05/01/2006 15:41, (e-mail address removed) wrote:

[snip]
POST /cgi-bin/xxxxxx/xxxxxxxxxxxxx HTTP/1.1

This is a POST request...

[snip]
Set-Cookie: SessieString=xxxxxxxxxxxxxxxx;
path=/cgi-bin/xxxxxx/xxxxxxxxxxxxx; v
ersion=1

....but Set-Cookie is a response header. You also seem to have a CRLF in
that value[1].
I tried Cookie instead of Set Cookie,

If you send

Cookie: SessieString=xxxxxxxxxxxxxxxx

there should be no problem.
with and without the path

The path parameter is not included in a Cookie request header. The
Cookie header consists only of name/value pairs.
en version

There is no version parameter for either Cookie or Set-Cookie.
and the letter with and without the semicolon.

I'm not quite sure what you mean there.
I used /r/n since the server is on unix (Apache) and I am sending from a
windows-client (Little C program written in g++).

It doesn't matter which operating system is used. Each header must be
terminated a CRLF pair (ASCII 13 + 10), and the entity body must be
separated from the headers by another CRLF pair.

Mike


[1] If that is just an error caused by automated wrapping from
your newsreader, you should do yourself (and others) a favour
by either explicitly noting the wrapping (to distinguish
intent from error) or, even better, wrap manually and
continue the header value on the following line (with the
necessary linear white space).

Set-Cookie: SessieString=xxxxxxxxxxxxxxxx;
path=/cgi-bin/xxxxxx/xxxxxxxxxxxxx;
version=1
 
M

marcwentink

Hi, thanks for the comments.

It works, I should do

Cookie: SessieString=xxxxxxxxxxxxxxx

since this is a request : browser --to--> server

For your interest, I did try something like that before, but then

Cookie: xxxxxxxxxxxxxxx

and of course:

Cookie:xxxxxxxxxxxxxx
Cookie:"xxxxxxxxxxxxxxxx"

It's hard to see what wrong sometimes, with socket programming and
message generation. Thanks for all the help!
 
M

marcwentink

Mr. Winter:
If you send
Cookie: SessieString=xxxxxxxxxxxxxxxx
there should be no problem.

You're right, that was is. It was indeed browser to server. Before my
Set-Cookie attempt, I did try

"Cookie: xxxxxxxxxxxxxx",

without 'SessieString='. That was not working. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top