The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Problem with coookies plz help
Discuss Problem with coookies plz help in the PHP Development forum on Dev Shed. Problem with coookies plz help PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 7th, 2000, 12:19 AM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 20
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Sir im using the following code to store cookies into the client computer but it works on some machine . i don;t know why it;s not working on the same machin which is accepting java cookeis but not accepting php cookeis
here is the code
setcookie("computerid",$computerid,time()+94608000,"/","www.mycompany.com","");
Plzx help me
|

May 7th, 2000, 03:04 AM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I had the same problem recently. Lynx recognized my cookies but netscape or exploder not.
There is something special with cookies format?
------------------
Belu Bogdan - cobra@ines.ro
webmaster
INES Internet
|

May 7th, 2000, 03:58 AM
|
 |
.Net Developer
|
|
Join Date: Feb 2000
Location: London
Posts: 987
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
|
|
jdma79,
see,first whether your cookie is set or not.
Another reason,
Probably your clients computer must have switched off the cookie option.
for checking whether cookie is successfully you can use:
if(isset($computerid)){
print "Cookie is setn";
}
Visit the following link for solving your problem...
http://www.phpbuilder.com/manual/fu....setcookie.php3
GOOD LUCK!!!
------------------
SR -
shiju.dreamcenter.net
|

May 7th, 2000, 11:26 PM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Here is code to test the ability to save a cookie on a browser. Also note some useful methods of storing cookies. This is a compilation of tips and tricks found on php.net. Works on Linux, 95, 98 ,NT IE 4 and Netscape 4.5-
<?
function store_array_in_cookie($cookiename, $array2store) {
$tmpstring = serialize($array2store);
setcookie($cookiename, $tmpstring, time()+3600*5, "/");
unset($tmpstring);
}
function erase_array_in_cookie($cookiename, $array2store) {
$tmpstring = serialize($array2store);
setcookie($cookiename, $tmpstring, time()-3600*5, "/");
unset($tmpstring);
}
function erase_set_array_cookie($cookiename, $array2store) {
$tmpstring = serialize($array2store);
setcookie($cookiename, $tmpstring, time()-604800, "/");
setcookie($cookiename, $tmpstring, time()+604800, "/");
unset($tmpstring);
}
function erase_set_array_cookie_header($cookiename, $array2store) {
$time = mktime()+36000;
$backtime = mktime()-36000;
$date = date("l, d-M-y H:i:s", ($time));
$backdate = date("l, d-M-y H:i:s", ($backtime));
$tmpstring = serialize($array2store);
$tmpstring = urlencode($tmpstring);
// header("Set-Cookie: $cookiename=$tmpstring; expires=$backdate GMT; path=/; domain=.biospectra.netn");
// header("Set-Cookie: $cookiename=$tmpstring; expires=$date GMT; path=/; domain=.biospectra.netn");
// header("Location: <A HREF="http://www.biospectra.net/index.php3n");" TARGET=_blank>http://www.biospectra.net/index.php3n");</A>
// exit;
header("Set-Cookie:$cookiename=$tmpstring;expires=$backdate GMT;path=/nSet-Cookie:$cookiename=$tmpstring;expires=$date GMT;path=/");
unset($tmpstring);
}
function erase_cookie_header($cookiename, $array2store) {
$backtime = mktime()-36000;
$backdate = date("l, d-M-y H:i:s", ($backtime));
$tmpstring = serialize($array2store);
$tmpstring = urlencode($tmpstring);
header("Set-Cookie: $cookiename=$tmpstring; expires=$backdate GMT; path=/");
unset($tmpstring);
}
function store_cookie_header($cookiename, $array2store) {
$time = mktime()+36000;
$date = date("l, d-M-y H:i:s", ($time));
$tmpstring = serialize($array2store);
$tmpstring = urlencode($tmpstring);
header("Set-Cookie: $cookiename=$tmpstring; expires=$date GMT; path=/");
unset($tmpstring);
}
function get_array_from_cookie($cookiename) {
$tmpstring = "global $$cookiename";
eval($tmpstring);
unset($tmpstring);
if (isset(${$cookiename})) {
$tmparray=unserialize(stripslashes(${$cookiename}));
} else {
$tmparray = array();
}
while (list($name, $value) = each($tmparray))
printf("type="hidden" name="%s" value="%s"<BR>n", $name, $value);
return $tmparray;
}
$cookiename="cookiearray";
if (!($submit_store == "")) {
$array2store=array(bbaez,nim101,15,0,0);
store_array_in_cookie($cookiename, $array2store);
};
if (!($submit_erase == "")) {
$array2store=array(bbaez,nim101,15,1,1);
erase_array_in_cookie($cookiename, $array2store);
};
if (!($submit_erase_store_set == "")) {
$array2store=array(bbaez,nim101,15,1,1);
erase_set_array_cookie($cookiename, $array2store);
};
/**********************************************************************************/
if (!($submit_store_header == "")) {
$array2store=array(bbaez,nim101,15,0,0);
store_cookie_header($cookiename, $array2store);
};
if (!($submit_erase_store_header == "")) {
$array2store=array(bbaez,nim101,15,1,1);
erase_set_array_cookie_header($cookiename, $array2store);
};
if (!($submit_erase_header == "")) {
$array2store=array(bbaez,nim101,15,1,1);
erase_cookie_header($cookiename, $array2store);
};
/**********************************************************************************/
if (!($submit_retrieve == "")) {
get_array_from_cookie($cookiename);
};
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<form action="<? echo $PHP_SELF ?>" method="POST">
<input type="submit" name="submit_store" value="Click To Store">
<input type="submit" name="submit_erase_store_set" value="Click To Erase and Store Using setcookie()">
<input type="submit" name="submit_erase" value="Click To Erase">
<P>
<P>
<input type="submit" name="submit_store_header" value="Click To Store Using the Header">
<input type="submit" name="submit_erase_store_header" value="Click To Erase and Store Using Header">
<input type="submit" name="submit_erase_header" value="Click To Erase Using the Header">
<P>
<P>
<input type="submit" name="submit_retrieve" value="Click To Retrieve">
</form>
</BODY>
</HTML>
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|