473,790 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cookies not deleted in browser

134 New Member
Hi

i m using cookies to store data in an form containing textfields

and using the following codes.,



Expand|Select|Wrap|Line Numbers
  1. <?
  2. $act=$_REQUEST['act'];
  3.  
  4. if($act==1)
  5. {
  6. $one=$_POST['1'];
  7. $two=$_POST['2'];
  8. $three=$_POST['3'];
  9.  
  10. setcookie ('field[1]', $one);
  11. setcookie ('field[2]', $two);
  12. setcookie ('field[3]', $three);
  13. ?>
  14. <meta http-equiv="refresh" content="0;url=cook.php">
  15. <?
  16.  
  17. }
  18. if($act=="del")
  19. {
  20. $f=$_REQUEST['f'];
  21.  
  22. if($f==1)
  23. setcookie ("field[1]", FALSE);
  24. else if($f==2)
  25. setcookie ("field[2]", FALSE);
  26. else if($f==3)
  27. setcookie ("field[3]", FALSE);
  28.  
  29. ?>
  30. <meta http-equiv="refresh" content="0;url=cook.php">
  31. <?
  32.  
  33. }
  34. $onec=$_COOKIE['field']['1'];
  35. $twoc=$_COOKIE['field']['2'];
  36. $threec=$_COOKIE['field']['3'];
  37. ?>
  38.  
  39. <form name="form1" method="post" action="cook.php?act=1">
  40. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  41.   <tr>
  42.     <td width="12%" height="22" align="center" valign="middle"><span class="style1">1</span></td>
  43.     <td width="75%" align="center"><label>
  44.       <input name="1" type="text" id="1" style="border:#FFFFFF; color:#CC3366;background:#FAECDF; border:none; " size="30" value="<? if($act==1) echo $one; else echo $_COOKIE['field']['1'];?>" />
  45.     </label></td>
  46.     <td width="13%"><a href="cook.php?act=del&amp;f=1"><img src="images/delete-btn.png" alt="exitbtn" width="15" height="15" border="0"/></a></td>
  47.   </tr>
  48.   <tr>
  49.     <td height="25"align="center" valign="middle"><span class="style3">2</span></td>
  50.     <td align="center" valign="middle"><input name="2" type="text" id="2" style="border:#FFFFFF; color:#CC3366;background:#FAECDF; border:none; " size="30" value="<? if($act==1) echo $two; else echo $_COOKIE['field']['2'];?>" /></td>
  51.     <td><a href="cook.php?act=del&amp;f=2"><img src="images/delete-btn.png" alt="exitbtn" width="15" height="15" border="0"/></a></td>
  52.   </tr>
  53.   <tr>
  54.     <td height="23" align="center" valign="middle"><span class="style1">3</span></td>
  55.     <td align="center"><input name="3" type="text" id="3" style="border:#FFFFFF; color:#CC3366;background:#FAECDF; border:none; " size="30" value="<? if($act==1) echo $three; else echo $_COOKIE['field']['3'];?>" /></td>
  56.     <td><a href="cook.php?act=del&amp;f=3"><img src="images/delete-btn.png" alt="exitbtn" width="15" height="15" border="0"/></a></td>
  57.   </tr>
  58. </table>
  59. </form>
  60.  
  61.  


when i implemented the above code.,

i got all the results perfectly.,

but in IE when i clear the cookies using the browser options i didnt get the cookies cleared and values are displayed in the corresponding fields.,

How can this possible., the cookies should get cleared right?


regards
vijay
Jul 5 '08 #1
14 5223
Markus
6,050 Recognized Expert Expert
. .
Jul 5 '08 #2
realin
254 Contributor
code is so messed up.. cant get it and tired to copy paste into my own editor :p
Jul 5 '08 #3
Markus
6,050 Recognized Expert Expert
If this only happens in IE, it shouldn't be a php problem, but a browser one.
Jul 5 '08 #4
pbmods
5,821 Recognized Expert Expert
Heya, vjayis.

Try setting an expiration date for your cookie that is in the past:

Expand|Select|Wrap|Line Numbers
  1. setcookie('field', false, time() - 86400);
  2.  
Jul 5 '08 #5
vjayis
134 New Member
Hi

thts wasn't my problem.,

i m simply ssetting up cookies when the save button is clicked and the cookies is set.,

but

when i clear cookies through the browser options i didnt get the cookies cleared up only in ie.,

and this is the code i hav used to set the cookie

Expand|Select|Wrap|Line Numbers
  1. setcookie ('field[1]', $one);
  2.  

thanks
Jul 7 '08 #6
pbmods
5,821 Recognized Expert Expert
oic

IE might be showing a cached version of the page. If you refresh the page, do you still see the values pre-populated?
Jul 7 '08 #7
vjayis
134 New Member
Actually when i submit the form i m setting the new value to the cookie and refreshing the page using meta http.

so while refreshing i m getting the correct datas.,

but the cookies are not cleared if i m deleting it through browser options.,

and if i m doing the same by setting the cookies value to false it works fine.,
Jul 7 '08 #8
vjayis
134 New Member
Actually when i submit the form i m setting the new value to the cookie and refreshing the page using meta http.

so while refreshing i m getting the correct datas.,

but the cookies are not cleared if i m deleting it through browser options.,

and if i m doing the same by setting the cookies value to false it works fine.,


hey is there no one to answer me??

i ll explain once again

1.first page containing form.,

2.second page is called and textfield value is taken and the cookies is set using the function
Expand|Select|Wrap|Line Numbers
  1. $textfield1=$_POST['textfield1'];
  2. setcookie("fieldvalue1",$textfield1,time()+(60*60*24*365),'/');
  3.  
and i m redirecting the it to the first page.

3.displaying the cookie value.

this is wat i m doing.,

works well in firefox and the cookie gets cleared when i clear the cookies through browser options.,

but in IE if i clear the cookies through browser options i still get the cookie value displayed in the first page.,

but if i delete the cookies along with the temp.internet files the cookie value is not yet displayed in my page.,

i m posting my code here

first page

Expand|Select|Wrap|Line Numbers
  1. <?
  2. //verifying the cookie results
  3. echo $_COOKIE['fieldvalue1'];
  4. echo $_COOKIE['fieldvalue2'];
  5. ?>
  6. <form id="form1" name="form1" method="post" action="cooksave.php">
  7.   <table width="100%" border="0" cellspacing="0" cellpadding="0">
  8.     <tr>
  9.       <td>1. Enter first value </td>
  10.       <td><input name="textfield1" type="text" id="textfield1"  value="<? echo $_COOKIE['fieldvalue1'];?>"/></td>
  11.     </tr>
  12.     <tr>
  13.       <td>2. Enter second value </td>
  14.       <td><input type="text" name="textfield2"  value="<? echo $_COOKIE['fieldvalue2'];?>"/></td>
  15.     </tr>
  16.     <tr>
  17.       <td>&nbsp;</td>
  18.       <td><input type="submit" name="Submit" value="Submit" /></td>
  19.     </tr>
  20.   </table>
  21. </form>
  22.  

second page

Expand|Select|Wrap|Line Numbers
  1. <?
  2.     $textfield1=$_POST['textfield1'];
  3.     $textfield2=$_POST['textfield2'];
  4.  
  5.     setcookie("fieldvalue1",$textfield1,time()+(60*60*24*365),'/');
  6.     setcookie("fieldvalue2",$textfield2,time()+(60*60*24*365),'/');
  7.  
  8. ?>
  9. <meta http-equiv="refresh" content="0;url=cookie.php">
  10.  
Jul 8 '08 #9
Markus
6,050 Recognized Expert Expert
As pbmods already suggested, IE is showing you a cached version of the page. I'm going to say it again: you're not using PHP to delete the cookies, but the browser. Therefore, this isn't a PHP problem.
Jul 8 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
4063
by: Phil Powell | last post by:
I am having this problem: My PHP script will set a cookie, it's there in my /Cookies folder. I delete the cookie (I have to for testing purposes, the PHP script I run behaves according to this cookie existing or not) and run the script again. Everything runs fine, but the cookie is never set again. Does anyone know why this happens? I am using Win2000 Professional with IE 6. Cookies are being set with PHP and Javascript. Thanx Phil
3
1816
by: John | last post by:
I am storing user names and addresses in cookies so that they do not have to enter them in forms. But now if I try to send the form with new data, the data in cookies is always called when I press the submit button. The data that I have entered get deleted and the data in the cookies is submitted. This also happens in scripts where I am not even using cookies to set the forms. How do I solve this problem? Thank you John
2
3347
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of the user. I want that cookie should get deleted when user closes the browser without signing out. I think it is done in global.asa file . But i don;t know how to do it?
9
2538
by: | last post by:
Is it possible for a user to enable permanent cookies but disable session cookies.....this seems like a contradition yet this is what I appear to be reading in online articles?
5
1934
by: anony | last post by:
Hi, I have a site that uses forms authentication to secure the directory. The site behaves as expected when viewed externally... if I close the browser and attempt to access it again, I get prompted to login. However, locally here on the network, if I close the browser and open a new one and access the site again, I don't have to login. Can anyone shed some light as to what's going on? Thanks,
5
5347
by: Miljana | last post by:
Hi, I have one problem with cookies in ASP.NET application. It seems that I can not retreive cookie from Request.Cookies collection. I put cookie in Response.Cookies collection, and after page post back, when I try to retreive it from Request.Cookies collection, it appears that it does not exists. This problem does not occur on several developing machines we use for developing application, but occurs in another environment (another...
7
2019
by: Marcus | last post by:
I know that when you start a session in PHP, the "cookie" it creates is not the same as those that are stored in your browser's temp folder, and instead is kept in RAM. I am confused because in every session tutorial I have ever read, the author invariably mentions the 2 main ways of propagating sessions - through cookies and appended to the URL. The author also almost always talks about the method being dependent on the user's...
2
1321
by: the friendly display name | last post by:
Easy to describe that problem: The cookies will be deleted after the user closes the browser, but I have set persistance to true. Code: ------ TicketForPremium = new FormsAuthenticationTicket(1, UserID, DateTime.Now, DateTime.Now.AddHours(10), true, "1"); TicketForPremiumCrypted = FormsAuthentication.Encrypt(TicketForPremium); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,
7
10210
by: cmrchs | last post by:
Hi, In Windows Vista: where does asp.net write its cookies? I use HttpCookie objCookie = new HttpCookie("nameCookie"); in Win2000 (and later) they used to be in C:\Documents and Settings\Administrator\Cookies but not anymore
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.