473,386 Members | 1,715 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,386 software developers and data experts.

Deleting Cookies

46
Hey Everyone:
I dunno if it's just really late and i cant see the blatantly obvious error right in front of me, or there's something im doing thats completely out of my knowledge. Anyway, i ask you, is there anything wrong with this block of code:
[php]
if(isset($_COOKIE['lastMob'])){
$lastMob = $_COOKIE['lastMob'];
print "Cookie was set to: ".$_COOKIE['lastMob']."<br />";
setcookie("lastMob", "", time()-3600);
}else{
$lastMob = rand()%$numrows;
setcookie('lastMob',$lastMob);
print "Cookie was not set... setting cookie to ".$lastMob."<br />";
}
[/php]
Correct me if Im wrong: setcookie("lastMob", "", time()-3600) should kill the cookie right? Everytime i run this code the cookie never dies. it just sits there taunting me. What's wrong with my code?
Jan 26 '08 #1
1 1513
stepterr
157 100+
This is what I use and it works like a charm. I have two cookies, "ID_my_site" and "Key_my_site".


[PHP]
<?php
$past = time() - 100;
//this makes the time in the past to destroy the cookie
setcookie(ID_my_site, gone, $past);
setcookie(Key_my_site, gone, $past);
header("Location: login.php");
?>[/PHP]
Jan 27 '08 #2

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

Similar topics

5
by: Rosa | last post by:
Hi, I'm trying to clear the TIF on Windows XP programmatically with the below code. This code works fine on any folder but the TIF. For some reason the atEnd() statements always defaults to true...
14
by: Alec S. | last post by:
Hi, I'm using JavaScript and Cookies for some customization in a web page. There may be several values in the cookie with names that are not known at runtime. I need a way of deleting them. ...
1
by: Michal A. Valasek | last post by:
Hello, I have problem deleting cookies and cookies values (using framework version 1.1 on W2003). When I try to remove entire cookie, by calling Response.Cookies.Remove("Test"), nothing...
2
by: James | last post by:
Help! I've made a cookie with a key called 'List' and subkey 'item3' and assigned it a value of "3" Response.Cookies("List")("item3")="3" How do I now delete the subkey "item3" without...
4
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, if I have this cookie header in a response: Set-Cookie: CookieName=; path=/;expires=01-Jan-1999 00:00:00 GMT the...
4
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, i make more than one request and needs to handle cookies being added and removed between requests, just like a regular...
1
by: sameer | last post by:
Hi all, Environment : ASP.NET I am using cookies to store some data. this is done in a class which is called by a web page CookieCreate.aspx. Here is a little bit of code of how i create the...
2
by: =?Utf-8?B?YmlsbA==?= | last post by:
Hi I run windows EP service pack 2.I am on internet explorer 7.When I go into tools option delete history cookies ,temp file & so on .It doesnt work .I have deleted & reinstalled expl 7 but it...
2
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Fedora Core 5 Linux. Two questions, if I create a cookie under the "/" path ... setcookie('LoggedIn', 1, time() + REMEMBER_ME_TIME, "/"); 1. How do I check if...
9
by: divyakgowda | last post by:
Hello, For my ruby on rails application,i need to delete all the temporary files created in /tmp folder.If those files increases, at some point in time, my application stops working unless i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
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...

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.