473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Cookies not deleted in browser

134 100+
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 5195
Markus
6,050 Expert 4TB
. .
Jul 5 '08 #2
realin
254 100+
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 Expert 4TB
If this only happens in IE, it shouldn't be a php problem, but a browser one.
Jul 5 '08 #4
pbmods
5,821 Expert 4TB
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 100+
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 Expert 4TB
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 100+
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 100+
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 Expert 4TB
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
vjayis
134 100+
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.



then what is the solution for this??

is there no way?
Jul 10 '08 #11
TheServant
1,168 Expert 1GB
then what is the solution for this??

is there no way?
So have you tried refreshing the page manually? If you can't, remove the meta refresh in your code and try again.

Have you set your cookie expiration anywhere, like your php.ini file (if that is where it is defined)? Have you tried it on a different computer/different browser?

If you have a cookie which won't allow itself to be removed then you have pretty amazing cookie. Otherwise you will need to try a browser troubleshooting page.

Are the cookies going into the usual cookie place? As in where your cookies usually go?
Jul 10 '08 #12
vjayis
134 100+
So have you tried refreshing the page manually? If you can't, remove the meta refresh in your code and try again.

Have you set your cookie expiration anywhere, like your php.ini file (if that is where it is defined)? Have you tried it on a different computer/different browser?

If you have a cookie which won't allow itself to be removed then you have pretty amazing cookie. Otherwise you will need to try a browser troubleshooting page.

Are the cookies going into the usual cookie place? As in where your cookies usually go?

Tried refreshing the page by both ways.,

No i didnt hav set my cookie to expire anywhere.,

and already tried with different computers and browsers.

and my cookie is going to the usual cookie place only.,
i m damn sure abt this.,
Jul 10 '08 #13
TheServant
1,168 Expert 1GB
What is your cookie named? And just checking, the cookies from your site are the only ones not deleting? There are no other persistant cookies?
Jul 10 '08 #14
vjayis
134 100+
hi

my cookies alone are not deleted.,
i tried by using the link

http://www.labpixies.com/campaigns/todo/todo.html

and this too shows the cached page when i tried by deleting the cookies through browser settings(IE).,

but if i press delete all instead of pressing delete cookies in browser options., i get the new page with all cookies deleted.


and one more question

is there a limit to set number of cookies??

i need to set upto 30 cookie variables.,

is it possible.,

firefox allows me to set more than 30 cookie variables.,

but IE allows only 20 cookie variables to be set., if i m setting next cookie variable then the first cookie variable i had set gets expired..,

but i'm in need to set about 20 to 30 cookie variables.,

is there any way??
Jul 11 '08 #15

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

Similar topics

7
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...
3
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...
2
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...
9
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
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...
5
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...
7
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...
2
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...
7
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.