Question about cookies

Reply

Join Date: Apr 2009
Posts: 64
Reputation: Tekkno is an unknown quantity at this point 
Solved Threads: 1
Tekkno Tekkno is offline Offline
Junior Poster in Training

Question about cookies

 
0
  #1
Aug 15th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 150
Reputation: sDJh is an unknown quantity at this point 
Solved Threads: 13
sDJh sDJh is offline Offline
Junior Poster

Re: Question about cookies

 
0
  #2
Aug 16th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 64
Reputation: Tekkno is an unknown quantity at this point 
Solved Threads: 1
Tekkno Tekkno is offline Offline
Junior Poster in Training

Re: Question about cookies

 
0
  #3
Aug 17th, 2009
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:
  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:
  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:
  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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 64
Reputation: Tekkno is an unknown quantity at this point 
Solved Threads: 1
Tekkno Tekkno is offline Offline
Junior Poster in Training

Re: Question about cookies

 
0
  #4
Aug 18th, 2009
nobody?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC