how to destroy the cookies when the browser is closed?

Reply

Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

how to destroy the cookies when the browser is closed?

 
0
  #1
Feb 12th, 2008
how to destroy cookies when the browser is closed? i have a php script where initially the user logs in and then the subsequent pages are displayed.i want that if the user closes the browser in between n tries to re-open the same page, he gets the error message that he has to login first (i.e the cookies which i have set once the user is logged in shud be destroyed once the user closes the browser.I am able to destroy my cookie after log out,but don't know how to destroy this when I will close the browser.
Last edited by carobee; Feb 12th, 2008 at 2:37 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 567
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: how to destroy the cookies when the browser is closed?

 
0
  #2
Feb 12th, 2008
you can destroy the cookie by closing the browser if you set the cookie through javascript.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

Re: how to destroy the cookies when the browser is closed?

 
0
  #3
Feb 12th, 2008
i have used php. is there any way to do in php?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 567
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: how to destroy the cookies when the browser is closed?

 
0
  #4
Feb 12th, 2008
You can use PHP and javascript together.I have never thought of solving your problem in PHP.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

Re: how to destroy the cookies when the browser is closed?

 
0
  #5
Feb 12th, 2008
can you help me with the code in javascript? i am very new to javascript
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 567
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: how to destroy the cookies when the browser is closed?

 
0
  #6
Feb 12th, 2008
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 205
Reputation: carobee is an unknown quantity at this point 
Solved Threads: 11
carobee carobee is offline Offline
Posting Whiz in Training

Re: how to destroy the cookies when the browser is closed?

 
0
  #7
Feb 12th, 2008
i figured out a javascript to use with php, but here agn i am not sure where to place the code for erasing the cookies. also in my page there are links to other pages, so everytime i click on any link, the message pops up. how cn i avoid that?
  1.  
  2. <html>
  3. <body>
  4.  
  5. <script language="JavaScript">
  6. var needToConfirm = true;
  7.  
  8. window.onbeforeunload = confirmExit;
  9. function confirmExit()
  10. {
  11. if (needToConfirm)
  12. return "Are you sure you want to exit?";
  13. }
  14. </script>
  15. </body>
  16. </html>
Last edited by carobee; Feb 12th, 2008 at 6:25 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 23
Reputation: scottholmes is an unknown quantity at this point 
Solved Threads: 0
scottholmes scottholmes is offline Offline
Newbie Poster

Re: how to destroy the cookies when the browser is closed?

 
0
  #8
Feb 12th, 2008
if the cookie is set with time=0 it will expire when the browser is closed.
setcookie("name", "value", 0);
Scott Holmes
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC