Lively discussions on the graphic arts and publishing — in print or on the web

Go Back   Desktop Publishing Forum > General Discussions > Web Site Building & Maintenance

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 04-05-2010, 02:15 AM   #1
Join Date: May 2006
Location: Scottish Borders, UK
Posts: 208
Default cookies and screen resolution...

I came across a website (the Survey link at the bottom of the page) that gives an indication of users' screen resolutions. Of course, it only shows results for people who visit that particular site but it is interesting nonetheless.

So I wondered about compiling similar stats for my own site - how is it done? I'd thought that the screen res would be part of the environment variables and that you could simply extract the details. Apparently not.

Further research reveals that cookies are the way to go. I have absolutely no experience of setting or using them. Indeed, I have a bit of an ethical 'block' against inflicting cookies on other people's machines; particularly when it is of no benefit to them, but is simply for my own indulgence.

I found bits and bobs which use PHP and also Javascript and my limited experiments confirm that it can set and read a cookie containing the information. Further research will be needed because you don't, for example, want to count the same client more than once...

...but that's another story. The algorithm seems to be something along the lines of "if the cookie has been set then read it, otherwise set one and then read it" but I'm just not understanding how the sequence of events works.

It appears that cookies are site-specific and if a browser requests a page from a server, then any existing cookie information specific to that site is sent along with the request. I can follow that, but what happens if no cookie has been set? The example I came across uses Javascript to set the cookie if none exists but I'm thinking that would happen too late for the browser to send the information to the server if it only requests the page once.

On the other hand, the script that I tested does seems to work but how does it do it?

If anyone could shed some light on what the sequence of events should be - in simple terms, please - then I'd be grateful.

john_b is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Helvetica cookies (with yummy comments) ktinkel Fonts & Typography 11 02-01-2010 03:55 PM
NOT [edible] cookies Howard Allen The Corner Pub 10 10-02-2008 07:14 AM
Screen resolution? Bo Aakerstrom Hardware & Gadgets 7 08-30-2007 09:51 PM
Cookies, yummie and otherwise! Anne Wright The Corner Pub 38 06-18-2005 04:59 PM

All times are GMT -8. The time now is 03:20 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Contents copyright 2004–2019 Desktop Publishing Forum and its members.