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 8084077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:40:51+00:00 2026-06-05T17:40:51+00:00

I am setting a cookie, but having some issue. Currently the cookie format is

  • 0

I am setting a cookie, but having some issue. Currently the cookie format is this:

setcookie("company_id", $company_id, 0, '/');

So expiry time is set to 0 means cookie will never expire, but when I tried to not to set any expiry time so I passes an empty argument in the third parameter like this:

setcookie("company_id", $_POST["company_id"], "", '/');

But this is not working, cookie is not getting, when I changed the empty argument to 0 it than start working. Any suggestions?

  • 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-05T17:40:52+00:00Added an answer on June 5, 2026 at 5:40 pm

    The expire parameter is in seconds. Setcookie function

    All the arguments except the name argument are optional. You may also
    replace an argument with an empty string (“”) in order to skip that
    argument. Because the expire argument is integer, it cannot be skipped
    with an empty string, use a zero (0) instead.

    So unless you want it to expire at the end of the session you will need to have a value other than zero.

    0 suggests the cookie should expire at the end of the session, if you want it to ‘never expire’use a really long time.

    setcookie("TestCookie", $value, time()+3600*24*365*10, '/')
    

    Eg that would be ten years.

    Bear in mind people can clear cookies often. So yours may get deleted. Cookies are also browser specific, so if the data that is stored in this, is needed every-time, then if the user switches browser this will no longer be available unless you set it again.

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

Sidebar

Related Questions

So this is my first time using cookies and i'm having some trouble setting
I am having issue setting a cookie to a web-service call in .NET. Before
I currently have an issue with setting a cookie in a block of php
Everything I read about cookies says that setting the expiry time of a cookie
I am using Jquery Cookie but am having difficulty setting and retrieving the info.
I'm having a heck of a time setting a cookie in restlet, heres what
I'm having a problem setting a cookie and doing a 302 redirect In chrome
I am having trouble setting and echoing out a cookie, I was wondering if
I am having a problem where a cookie I am setting is being lost
I'm setting the curl cookiejar option with the following: curl_setopt($ch, CURLOPT_COOKIEFILE, cookie.txt); this puts

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.