Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cookie in IE7

1 view
Skip to first unread message

Pankaj

unread,
Oct 9, 2008, 10:11:17 AM10/9/08
to
I have st a cookie that would last for 30 days. If I put a line <img
src="http://www.example.com/readcookie.php" width="1" height="1"> in a
php file, I cannot read the cookie if I use IE7. However, it works in
Firefox and Chrome. If I try to access the URL http://www.example.com/readcookie.php
in IE7, I am able to read the cookie then.

I am using the following lines of code

to set the cookie

setcookie("TestCookie",$userid,time()+(60*60*24*30),"/"); -------------
> Sets the cookie

to read the cookie

$MyUserId = $_COOKIE['TestCookie']; -------------------------> Sets
the variable $MyUserId if I try to access the file containg this code
in browser. However, this code does not work if I include the file
containing this code.


R. Rajesh Jeba Anbiah

unread,
Oct 9, 2008, 1:21:16 PM10/9/08
to

When setting the cookie from server, it would require that you
reload the page. http://in2.php.net/setcookie

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jerry Stuckle

unread,
Oct 9, 2008, 1:25:13 PM10/9/08
to

Why are you trying to read a cookie with an <img> tag? That doesn't
make any sense.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

R. Rajesh Jeba Anbiah

unread,
Oct 9, 2008, 1:32:28 PM10/9/08
to
On Oct 9, 10:25 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Pankaj wrote:
<snip>

> Why are you trying to read a cookie with an <img> tag? That doesn't
> make any sense.

Possibly, he's spying his users (stats).

<OT>
How is life and economy going?
</OT>

R. Rajesh Jeba Anbiah

unread,
Oct 9, 2008, 1:39:28 PM10/9/08
to
On Oct 9, 10:32 pm, "R. Rajesh Jeba Anbiah"

<ng4rrjanb...@rediffmail.com> wrote:
> On Oct 9, 10:25 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
> > Pankaj wrote:
> <snip>
> > Why are you trying to read a cookie with an <img> tag? That doesn't
> > make any sense.
>
> Possibly, he's spying his users (stats).
>
> <OT>
> How is life and economy going?
> </OT>

Disregard OT, I thought I was replying to Geof

Geoff Berrow

unread,
Oct 9, 2008, 2:06:23 PM10/9/08
to
Message-ID:
<aafee92c-0550-480a...@n33g2000pri.googlegroups.com> from
R. Rajesh Jeba Anbiah contained the following:

>> <OT>
>> How is life and economy going?
>> </OT>
>
> Disregard OT, I thought I was replying to Geof

:-)

Mail me and we can catch up (use the address in the sig), Haven't seen
you post for ages..
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk

Michael Fesser

unread,
Oct 9, 2008, 4:16:39 PM10/9/08
to
.oO(Jerry Stuckle)

>Pankaj wrote:
>> I have st a cookie that would last for 30 days. If I put a line <img
>> src="http://www.example.com/readcookie.php" width="1" height="1"> in a
>> php file, I cannot read the cookie if I use IE7. However, it works in
>> Firefox and Chrome. If I try to access the URL http://www.example.com/readcookie.php
>> in IE7, I am able to read the cookie then.
>>
>> I am using the following lines of code
>>
>> to set the cookie
>>
>> setcookie("TestCookie",$userid,time()+(60*60*24*30),"/"); -------------
>>> Sets the cookie
>>
>> to read the cookie
>>
>> $MyUserId = $_COOKIE['TestCookie']; -------------------------> Sets
>> the variable $MyUserId if I try to access the file containg this code
>> in browser. However, this code does not work if I include the file
>> containing this code.
>>
>>
>>
>
>Why are you trying to read a cookie with an <img> tag? That doesn't
>make any sense.

It does. An HTTP request is an HTTP request, it doesn't matter if the
return is an HTML page or an image. If for example there's an image-
generating script, there might also be the need for reading some cookie
value, maybe the preferred image size or something like that.

In my own case some images can be delivered by a script from a protected
directory. Authentication is handled with a cookie-based session, so the
request for such an image _must_ contain the session cookie or the image
won't be delivered, because the authentication fails.

Micha

Pankaj

unread,
Oct 10, 2008, 1:38:51 AM10/10/08
to
On Oct 10, 1:16 am, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Jerry Stuckle)
>
>
>
> >Pankaj wrote:
> >> I have st a cookie that would last for 30 days. If I put a line <img
> >> src="http://www.example.com/readcookie.php" width="1" height="1"> in a
> >> php file, I cannot read the cookie if I use IE7. However, it works in
> >> Firefox and Chrome. If I try to access the URLhttp://www.example.com/readcookie.php

> >> in IE7,  I am able to read the cookie then.
>
> >> I am using the following lines of code
>
> >> to set the cookie
>
> >> setcookie("TestCookie",$userid,time()+(60*60*24*30),"/"); -------------
> >>> Sets the cookie
>
> >> to read the cookie
>
> >> $MyUserId = $_COOKIE['TestCookie']; -------------------------> Sets
> >> the variable $MyUserId if I try to access the file containg this code
> >> in browser. However, this code does not work if I include the file
> >> containing this code.
>
> >Why are you trying to read a cookie with an <img> tag?  That doesn't
> >make any sense.
>
> It does. An HTTP request is an HTTP request, it doesn't matter if the
> return is an HTML page or an image. If for example there's an image-
> generating script, there might also be the need for reading some cookie
> value, maybe the preferred image size or something like that.
>
> In my own case some images can be delivered by a script from a protected
> directory. Authentication is handled with a cookie-based session, so the
> request for such an image _must_ contain the session cookie or the image
> won't be delivered, because the authentication fails.
>
> Micha

I am tracking how many users from my site visited one of my partner
site and signed up there. AFAIK, I do not have another way of finding
this out. I do not think it is an issue with authentication because
the code works if the user agent is firefox/ opera/ chrome.

Pankaj

Jerry Stuckle

unread,
Oct 10, 2008, 7:52:37 AM10/10/08
to

Are both of these sites in the same domain?

This type of failure is usually caused by a higher security setting in
IE than the others.

Pankaj

unread,
Oct 10, 2008, 9:31:32 PM10/10/08
to
Rajesh, the page is reloaded. I tried to read the cookie after the
user has filled up a two page form

Pankaj

unread,
Oct 10, 2008, 9:32:46 PM10/10/08
to
Yes they are on the same domain

David Quinton

unread,
Oct 11, 2008, 2:38:23 AM10/11/08
to
On Fri, 10 Oct 2008 18:32:46 -0700 (PDT), Pankaj <pana...@gmail.com>
wrote:

>Yes they are on the same domain

and subdomain (i.e. both have "www")?
--
Free personal divertable Phone number: <http://www.bizorg.co.uk/personalnos.htm>

R. Rajesh Jeba Anbiah

unread,
Oct 13, 2008, 10:17:59 PM10/13/08
to
On Oct 11, 6:31 am, Pankaj <panah...@gmail.com> wrote:
> Rajesh, the page is reloaded. I tried to read the cookie after the
> user has filled up a two page form

Check the status bar--if it's been denied by the policy settings.
Probably your domain name or cookie name might be a trouble. Also, try
setting P3P policy header http://www.sitepoint.com/print/p3p-cookies-ie6/

0 new messages