473,683 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1716
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@pd7tw3n o, "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.9197 40$Xk.214042@pd 7tw3no...
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.9197 40$Xk.214042@pd 7tw3no...
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@pd7tw3n o, "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
5287
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 cookie. Here is the code I have now. In the header, I have the following: <SCRIPT language="JavaScript"> var cookieStatus; if (document.cookie.length > 0) { cookieStatus = 'Cookie exists with value ' + document.cookie; } else {
12
17994
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 home page during their time using the browser. However, if the user closes the browser, then reopens, the pop-up should appear again. (you may have guessed that this will be used for public access pc's.) I want to try as best I can to catch...
5
3312
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 document.cookie variable combine all cookie key=value pairs? All of the examples I've seen discuss referencing a specific cookie. I don't see how this is done. Cookies are usually named by the domain. If I want to reference a specific cookie, do I...
4
3811
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"> if(document.cookie.indexOf("beenHere1=true")!=-1) else
9
4491
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 in a cookie and a small bullit shown in front of the hyperlink, so when I reload the page I can immediately see which hyperlinks I already visited that day.
3
11113
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 behind and don't use a domain then I can not change or remove that cookie's value on the client. If I subsequently create the cookie again in the codebehind then I actually end up with TWO cookies with the same name in the response. The cookie...
1
6705
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 simply pass the values in a cookie to the querystring that would be even easier, but from what I've been able to tell, cookie values can't be passed to a querystring. I'm sure the answer will help alot of others who are using this script, and would...
4
5711
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 pageA.asp I then try to read the cookie from pageB.asp, which is inside a frame of pageC.asp.
6
2697
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 problem is how do I handle the "path" parameter in cookie. First, the sequence start at http://www.testServer1.com/TestApp/page1.htm, and a cookie is set at
0
8922
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8751
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7581
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6429
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4519
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2934
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.