Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6535287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:21:21+00:00 2026-05-25T10:21:21+00:00

I am trying to implement this: http://adaptive-images.com/ into a website. It will rely on

  • 0

I am trying to implement this: http://adaptive-images.com/ into a website.
It will rely on JS-Cookies that will get the screen’s resolution so the PHP script that adapts the image sizes knows what resolution to deliver.
Unfortunately it somehow fails to set the cookie (and falls back to 480 resolution…) and I have no idea why. What it does is simply:

<script type="text/javascript">
document.cookie='resolution='+Math.max(screen.width,screen.height)+'; expires=; path=/';
</script>

right in the head of the document. Yet, the cookie never seems to be set, I will only see (they should appear in the Resources Part of the Chrome DevTools, right?) the GoogleAnalytics-created ones (yet, this does not seem to be the problem as removing GA makes no difference).

I never used JS cookies before, but from what I can read on the web the syntax seems to be perfectly fine and also I do not get any kind of error messages in the console or elsewhere, it just seems to ignore the cookie setting action.

A long story short: I have no idea what’s going on here?

Thanks!

EDIT: Maybe this is a PHP sided problem so I’ll add this part too.
What happens is the following:

First off:

$resolutions   = array(1920,1382, 992, 768, 480);

Then:

  if (is_numeric($_COOKIE['resolution'])) {
    $client_width = (int) $_COOKIE["resolution"]; 

    rsort($resolutions); 
    $resolution = $resolutions[0]; 

    foreach ($resolutions as $break_point) { 
      if ($client_width <= $break_point) {
        $resolution = $break_point;
      }
    }
  } 

Yet, the script will aways return a 480 resolution, even though my screen is 1920? As far as I get the code it should be returning 1920 so I guess it seems to use the fallback in case $_COOKIE['resolution'] is not set, which would be going back to 480.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:21:22+00:00Added an answer on May 25, 2026 at 10:21 am

    Not setting an expires time makes your cookie a session cookie so it only lasts for the lifetime of the browser session (it is not written to disk).

    Other than that, your cookie seems to work for me. When I use that code in a jsFiddle and look in the Chrome debugger at the cookies, I see the cookie string with an item in it for resolution and it’s marked as a session cookie, not a permanent cookie.

    Perhaps you can describe how you are reading the cookie?

    It occurs to me that you’re setting the cookie on the client so the server will not see the cookie until the NEXT page requested on that domain. The server won’t see it for the first page. Could this be your issue?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement this gallery on my website. http://coffeescripter.com/code/ad-gallery/ It is noted in the
I am trying to implement this JQuery ImageBubbles that I found here: http://www.dynamicdrive.com/dynamicindex4/imagebubbles.htm However,
I'm trying to implement this project: http://img7.imagebanana.com/img/cnb46ti2/relationships.png I want to let view the skills
I am trying to implement this example http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html and i have followed exactly all
I'm trying to implement a slideshow like this one: http://biggayicecreamtruck.com but for the life
I am trying to implement Lucene with cakephp and following this guide http://jamienay.com/2010/01/zend_search_lucene-datasource-for-cakephp/ Am
I am trying to implement this multi-touch android tutorial http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-5-implementing-the-drag-gesture/1789?tag=mantle_skin;content I am stuck in
Im trying to implement this code: http://wcf.codeplex.com/wikipage?title=Getting%20started:%20Building%20a%20simple%20web%20api and want to add it to my
I'm trying to implement mpdf in CodeIgniter according to this article: http://codeigniter.com/wiki/mPDF_with_Codeigniter I did
I am trying to implement this example http://blog.evonet.com.au/post/Gridview-with-highlighted-search-results.aspx but the only problem I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.