473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Cookie Woes :0(

O, woe is me, to have seen what I have seen, see what I see!

(That's Shakespeare for those who were wondering what I'm on about)

I am "having fun" with cookies.

And I wonder if I have missed something obvious.

I am writing a simple shopping cart that uses cookies.

It works as I expected in IE6 (Microsoft, all is forgiven...)

But it only half works in NN7, Firefox or Opera 7 (they are the only ones I
have tested so far)

Without pasting in reams of code, here is an overview of what it does.

When the visitor clicks on BUY PRODUCT, a row is inserted into the ORDER
TABLE that includes the cookie_id and product _id (amongst others)

This works in perfectly all browsers.

Next, a query is run to find all of the rows in the ORDER TABLE that have
the user's cookie_id, and the results are output as a summary of the order.

This works as expected in IE6 (Big up tha man like BillG)

But gives me no results in any of the other browsers

Any simple answers?

TIA

Mark
Jul 17 '05 #1
7 1696
Mark wrote:
O, woe is me, to have seen what I have seen, see what I see!

(That's Shakespeare for those who were wondering what I'm on about)

I am "having fun" with cookies.

And I wonder if I have missed something obvious.

I am writing a simple shopping cart that uses cookies.

It works as I expected in IE6 (Microsoft, all is forgiven...)

But it only half works in NN7, Firefox or Opera 7 (they are the only ones I
have tested so far)

Without pasting in reams of code, here is an overview of what it does.

When the visitor clicks on BUY PRODUCT, a row is inserted into the ORDER
TABLE that includes the cookie_id and product _id (amongst others)

This works in perfectly all browsers.

Next, a query is run to find all of the rows in the ORDER TABLE that have
the user's cookie_id, and the results are output as a summary of the order.

This works as expected in IE6 (Big up tha man like BillG)

But gives me no results in any of the other browsers

Any simple answers?

TIA

Mark

If at all possible, try to use sessions, they're not any harder than
cookies, and more secure. You can store the user's shopping list in a
serialized array, as to avoid the slow downs of MySQL access. Here's
some sample code:

When the user clicks Buy Product:
<?php
$_SESSION['list'][] = $product_id; //You get this ID from wherever the
user clicked Buy Product
?>

Make sure that you put session_start(); at the top of every page of your
site, in order for your list to carry over if they add more items to the
list. Also, this is almost guaranteed to solve your browser woes.

--
Ivan Filippov
Jul 17 '05 #2
In comp.lang.php Mark <ha****@hahaha.com> wrote:
Next, a query is run to find all of the rows in the ORDER TABLE that have
the user's cookie_id, and the results are output as a summary of the order.

This works as expected in IE6 (Big up tha man like BillG)

But gives me no results in any of the other browsers

Any simple answers?


If you'd tell me you code doesn; work in anything but IE I'd say your
code is broken. So post some code, this specific part should be more
than a couple of lines (summarize).

Next get a packetsniffer and check for differences between data send
when using IE vs. all others.

FUP c.l.p.

Jul 17 '05 #3
On 4/7/05 3:20 PM, in article 8ni5e.919740$Xk.214042@pd7tw3no, "Ivan
Filippov" <iv******@gmail.com> wrote:
If at all possible, try to use sessions, they're not any harder than
cookies, and more secure.


Is this at all true? Aren't PHP sessions tracked by cookies (or alternately
in a GET-readable and therefore thoroughly insecure query string addition)?

I keep on hearing this about PHP sessions being more secure than cookies,
and I guess that's true if you're storing sensitive data in cookies rather
than storing a ID and keeping the sensitive data on the server, but I don't
know why anyone would want to rely that heavily on client-side cookies for
data storage anyway.

Just asking,
Steve

Jul 17 '05 #4
Hi Ivan

Thanks for your response...

I have used sessions quite a lot, but didn't want to force a log on, and
wanted visitors to be able to come back under a different session and
continue with their order... That's why I was experimenting with cookies.
However...

I have fixed it...

And I feel such a fool!

I feel quite ashamed even admitting to my mistake, but my counsellor told me
that honesty is the only true path to enlightenment, and who am I to
disagree?

<shame>

I hadn't put ' ' around the cookie_id variable in the query...

And under examination, I found that the HEX cookie_id that had been
generated for IE just happened to be a huge integer (so it worked without '
'), whilst the cookie_ids assigned to the other browsers all had characters
in it, so the fact that it worked in IE was a completer fluke. Bill didn't
have anything to do with it...

</shame>

Mark (suitably chastened)

"Ivan Filippov" <iv******@gmail.com> wrote in message
news:8ni5e.919740$Xk.214042@pd7tw3no...
Mark wrote:
O, woe is me, to have seen what I have seen, see what I see!

(That's Shakespeare for those who were wondering what I'm on about)

I am "having fun" with cookies.

And I wonder if I have missed something obvious.

I am writing a simple shopping cart that uses cookies.

It works as I expected in IE6 (Microsoft, all is forgiven...)

But it only half works in NN7, Firefox or Opera 7 (they are the only ones
I have tested so far)

Without pasting in reams of code, here is an overview of what it does.

When the visitor clicks on BUY PRODUCT, a row is inserted into the ORDER
TABLE that includes the cookie_id and product _id (amongst others)

This works in perfectly all browsers.

Next, a query is run to find all of the rows in the ORDER TABLE that have
the user's cookie_id, and the results are output as a summary of the
order.

This works as expected in IE6 (Big up tha man like BillG)

But gives me no results in any of the other browsers

Any simple answers?

TIA

Mark

If at all possible, try to use sessions, they're not any harder than
cookies, and more secure. You can store the user's shopping list in a
serialized array, as to avoid the slow downs of MySQL access. Here's some
sample code:

When the user clicks Buy Product:
<?php
$_SESSION['list'][] = $product_id; //You get this ID from wherever the
user clicked Buy Product
?>

Make sure that you put session_start(); at the top of every page of your
site, in order for your list to carry over if they add more items to the
list. Also, this is almost guaranteed to solve your browser woes.

--
Ivan Filippov

Jul 17 '05 #5
Mark wrote:
Hi Ivan

Thanks for your response...

I have used sessions quite a lot, but didn't want to force a log on, and
wanted visitors to be able to come back under a different session and
continue with their order... That's why I was experimenting with cookies.
However...

I have fixed it...

And I feel such a fool!

I feel quite ashamed even admitting to my mistake, but my counsellor told me
that honesty is the only true path to enlightenment, and who am I to
disagree?

<shame>

I hadn't put ' ' around the cookie_id variable in the query...

And under examination, I found that the HEX cookie_id that had been
generated for IE just happened to be a huge integer (so it worked without '
'), whilst the cookie_ids assigned to the other browsers all had characters
in it, so the fact that it worked in IE was a completer fluke. Bill didn't
have anything to do with it...

</shame>

Mark (suitably chastened)

"Ivan Filippov" <iv******@gmail.com> wrote in message
news:8ni5e.919740$Xk.214042@pd7tw3no...
Mark wrote:
O, woe is me, to have seen what I have seen, see what I see!

(That's Shakespeare for those who were wondering what I'm on about)

I am "having fun" with cookies.

And I wonder if I have missed something obvious.

I am writing a simple shopping cart that uses cookies.

It works as I expected in IE6 (Microsoft, all is forgiven...)

But it only half works in NN7, Firefox or Opera 7 (they are the only ones
I have tested so far)

Without pasting in reams of code, here is an overview of what it does.

When the visitor clicks on BUY PRODUCT, a row is inserted into the ORDER
TABLE that includes the cookie_id and product _id (amongst others)

This works in perfectly all browsers.

Next, a query is run to find all of the rows in the ORDER TABLE that have
the user's cookie_id, and the results are output as a summary of the
order.

This works as expected in IE6 (Big up tha man like BillG)

But gives me no results in any of the other browsers

Any simple answers?

TIA

Mark


If at all possible, try to use sessions, they're not any harder than
cookies, and more secure. You can store the user's shopping list in a
serialized array, as to avoid the slow downs of MySQL access. Here's some
sample code:

When the user clicks Buy Product:
<?php
$_SESSION['list'][] = $product_id; //You get this ID from wherever the
user clicked Buy Product
?>

Make sure that you put session_start(); at the top of every page of your
site, in order for your list to carry over if they add more items to the
list. Also, this is almost guaranteed to solve your browser woes.

--
Ivan Filippov


You can serialize the session too and store it in your DB along with an
IP of the user. Most users nowadays have Anti-SpyWare software
installed which removes unwanted cookies which makes return visits with
the same cookie unlikely, either way though, wish you luck. :)

--
Ivan Filippov
Jul 17 '05 #6
Steven M. Scotten wrote:
On 4/7/05 3:20 PM, in article 8ni5e.919740$Xk.214042@pd7tw3no, "Ivan
Filippov" <iv******@gmail.com> wrote:

If at all possible, try to use sessions, they're not any harder than
cookies, and more secure.

Is this at all true? Aren't PHP sessions tracked by cookies (or alternately
in a GET-readable and therefore thoroughly insecure query string addition)?

I keep on hearing this about PHP sessions being more secure than cookies,
and I guess that's true if you're storing sensitive data in cookies rather
than storing a ID and keeping the sensitive data on the server, but I don't
know why anyone would want to rely that heavily on client-side cookies for
data storage anyway.

Just asking,
Steve

Quoth the PHP docs:
"A visitor accessing your web site is assigned an unique id, the
so-called session id. This is either stored in a cookie on the user side
or is propagated in the URL."

There are security risks with both methods, but good practice by the
user, such as logging out of the site before heading to another site
if using the URL propagation method. It's really up to the code monkey
in question concerning what they want to do, I personally find that
sessions are better for storing information, ease of access and
simplicity of implementation. Plus as I said in my reply to Mark,
sessions + DB works way better than cookies + DB. :)
--
Ivan Filippov
Jul 17 '05 #7
don't need any sort of logon to use sessions.

Also, in order to minimize the num of cookies I set on a users computer
I serialize an array and send that as the cookie.

I have send and write cookie funcs that automatically
serialize/deserialize if necessary

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shannon Jacobs | last post by:
I'm doing some trivial surveys, and I want to know if the same user answers twice. Can't really know that, but at least I thought I could check for the same browser/computer combination by using a...
12
by: chrism | last post by:
Hello, I have a pop-up window that I would like to appear in front of the browser home page when a user opens IE. Problem is, I'd like it to never appear again if the user navigates back to the...
5
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the...
4
by: socialism001 | last post by:
I'm trying to store a value in a cookie but its not working. Can anyone see what I might be doing wrong. Thanks, Chris ~~~~~~~~~~~~~~~~~~ <script language="javascript">...
9
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
1
by: CR1 | last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to...
4
by: Marcos | last post by:
Hi, This may or may not be a simple question, but I have been able to find an answer to this issue in all my searches. In an ASP application, I'm creating a cookie that stores a username from...
6
by: kelvlam | last post by:
Hello all, I'm still a bit new with JavaScript, and I hope the guru here can shed some light for me. It's regarding handling cookie and the case-sensitive nature of JavaScript itself. My...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.