943,778 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 519
  • PHP RSS
Aug 15th, 2009
0

Question about cookies

Expand Post »
I have a cookie script that creates a cookie from a session variable, the only problem is when the session is destroyed the cookie is deleted even though I set the expiration to a year. What can I do to prevent this?
Similar Threads
Reputation Points: 12
Solved Threads: 7
Junior Poster
Tekkno is offline Offline
134 posts
since Apr 2009
Aug 16th, 2009
0

Re: Question about cookies

Are you sure? Normally, when using session_destroy() the cookie isn't deleted - you have to do it manually. Maybe, you can post your code here, so that people get an ideo of your problem.
Reputation Points: 56
Solved Threads: 29
Posting Whiz in Training
sDJh is offline Offline
255 posts
since Aug 2005
Aug 17th, 2009
0

Re: Question about cookies

Yes, I am sure. I logged in, checked, and the cookie was there. I logged out, checked, and the cookie had been deleted. Here is my cookie script:
php Syntax (Toggle Plain Text)
  1. <?php if(isset($_SESSION['theme']));
  2. $theme = $_SESSION['theme'];
  3. setcookie(theme,$theme,time()+(60*60*24*365));
  4. ?>
Here is my logout script:
php Syntax (Toggle Plain Text)
  1. <?
  2. session_start();
  3. if($_SESSION["uname"]<> "") {
  4. session_unset();
  5. session_destroy();
  6. header( "Location:index.php" );
  7. exit();
  8. }
  9. ?>
Could it be because I am using isset to set the cookie possibly?

Well it's not the isset. Here is the revised code:
php Syntax (Toggle Plain Text)
  1. <?php if($_SESSION['theme']);
  2. $theme = $_SESSION['theme'];
  3. setcookie(theme,$theme,time()+(60*60*24*365));
  4. ?>
It's as if PHP is treating it as a session cookie.
Last edited by Tekkno; Aug 17th, 2009 at 2:33 pm.
Reputation Points: 12
Solved Threads: 7
Junior Poster
Tekkno is offline Offline
134 posts
since Apr 2009
Aug 18th, 2009
0

Re: Question about cookies

nobody?
Reputation Points: 12
Solved Threads: 7
Junior Poster
Tekkno is offline Offline
134 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: mail from SMTP authentication script doesn't seem to work
Next Thread in PHP Forum Timeline: convert anyfile to html





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC