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

  • Home
  • SEARCH
  • 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 7908507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:58:37+00:00 2026-06-03T11:58:37+00:00

I am currently running 2 versions of PHP. My local (test) server has 5.3.5,

  • 0

I am currently running 2 versions of PHP. My local (test) server has 5.3.5, while my remote (live) server has 5.2.4. This has caused a few compatibility issues in the past, but I’ve always been able to fix them pretty easily. Soon my remote server will be upgraded, so it won’t cause too many more issues, but in the mean time I still have to provide solutions for these stupid compatibility issues. Will someone please take a look at my code below and let me know if they spot any issues for a 5.2.4 PHP build?

function _cookie($name, $value) {
    $expire = strtotime('+1 month');
    $old_expire = strtotime('last day of next month');

    setcookie(
        $name,
        $value,
        $expire
    );
    var_dump($name, $value, $expire, $old_expire);
}

$date = date(
    'Y-m-d H:i:s',
    filemtime($file)
);
_cookie('user', 'bob');//works
_cookie('up2date', $date);//does not

I originally had ‘last day of next month’ as my cookie expiration date, which is why its still in the var_dump list. However, that string was returning false on the remote server causing cookies to expire at the end of the session. Even though it returned false, it would still set the “user” cookie and I was able to view it in the browser. It would not, however, set the “up2date” cookie. I thought this was odd, but figured it had something to do with the strtotime function returning false. So I tried fixing that first. After consulting the PHP manual I determined that the string I was using was only available on 5.3. There, problem confirmed, easy fix. I replaced it with the ‘+1 month’ string, which I know will work on 5.2. Success, my “user” cookie now expires as it should. Except I still dont have an “up2date” cookie. var_dump proves that the function is being called to set it and has all the correct parameters but it isn’t setting the second cookie. I wouldn’t be as frustrated if it just didn’t work at all. That would at least tell me that I was doing something wrong and I could weedle it out. But for it to tease me like this… What am I missing? Does anyone have any ideas?

var_dump results:

//Local server
string(4) "user"
string(3) "bob"
int(1337797496)
int(1338488696)

string(7) "up2date"
string(19) "2012-04-20 10:52:09"
int(1337797496)
int(1338488696)

//Remote server
string(4) "user"
string(3) "bob"
int(1337795061)
bool(false)

string(7) "up2date"
string(19) "2012-04-23 09:14:19"
int(1337795061)
bool(false)
  • 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-06-03T11:58:39+00:00Added an answer on June 3, 2026 at 11:58 am

    Thanks to DaveRandom. He deserves the credit here and if he adds his answer I’ll switch my accepted to his. I just added this answer so I don’t have any unanswered questions.

    The Solution: I had output before I called the second cookie so it was failing to set it. I just moved where I set the cookie.

    Thank you all for your suggestions and time!

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

Sidebar

Related Questions

PHP CLI has suddently stopped working on the server. When running any php file
I have a dedicated server that hosts a number of websites currently running PHP
I currently have a web server running PHP 5.2.13 and have recently been told:
I am currently developing a system on a server running PHP version 5.1.6 thus
I am currently running a PHP script that queries the database and then sends
I am currently developing an architecture in PHP and MySQL and a problem has
I have a web server that is running PHP 5.3.6 non thread safe (VC9),
I'm currently running Komodo 7 and have XDebug set up on PHP 5.3.1, which
We have an application hosted on both a local development server and a live
I am currently running Apache2 on my local machine, installed with the latest version

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.