setcookie

Google Chrome maximum cookie expiry date

自闭症网瘾萝莉.ら 提交于 2019-12-10 13:15:53
问题 I was creating my website when I created a new cookie with this php line : setcookie('subscribed', 'true', time() + 365*24*3600*100, '/', null, false, true); I realised my browser (Google Chrome) refused to get that cookie. When I looked at my cookies in Google Chrome it wasn't there. I started fiddling with the different settings until I saw that this worked : setcookie('subscribed', 'true', time() + 365*24*360, '/', null, false, true); Which meant that changing the expiration time to a

How to add / edit a cookie in php?

*爱你&永不变心* 提交于 2019-12-10 11:34:32
问题 I'm using the following functions to set an array of values in a cookie in PHP, but I also need an "add" and "edit" function - any suggestions on how I can do that? function build_cookie($var_array) { if (is_array($var_array)) { foreach ($var_array as $index => $data) { $out.= ($data!="") ? $index."=".$data."|" : ""; } } return rtrim($out,"|"); } function break_cookie ($cookie_string) { $array=explode("|",$cookie_string); foreach ($array as $i=>$stuff) { $stuff=explode("=",$stuff); $array[

php set cookie issue

南笙酒味 提交于 2019-12-09 00:52:24
问题 I'm setting a cookie on localhost with the following syntax setcookie("testCookie ", "hello cookie", false, "/", false); The problem is the first time I visit the page the cookie is created and firebug shows Cookie testCookie added. hello cookie But it does not read the value. If I refresh the page, the value is read and fire bug shows Cookie testCookie changed. hello cookie How can I get the value of the cookie to be read the first time the page is loaded? 回答1: As I put in my comment, from

Any reason why this code snippet wouldn't set a cookie properly?

纵饮孤独 提交于 2019-12-07 09:55:00
问题 This little PHP snippet is used to set a cookie that lets me determine whether or not a user is logged in. For some reason, after I use the javascript to redirect, none of my cookies are set any more. Any reason why this would be happening? I may not be giving you enough info so let me know if so. ...some database queries... <?php $expire=time()+(7 * 24 * 60 * 60); $row = mysql_fetch_array($query); $email = $row['email']; $userinfo['name'] = $name; $userinfo['email'] = $email; $userinfo =

How to add / edit a cookie in php?

孤人 提交于 2019-12-06 15:46:17
I'm using the following functions to set an array of values in a cookie in PHP, but I also need an "add" and "edit" function - any suggestions on how I can do that? function build_cookie($var_array) { if (is_array($var_array)) { foreach ($var_array as $index => $data) { $out.= ($data!="") ? $index."=".$data."|" : ""; } } return rtrim($out,"|"); } function break_cookie ($cookie_string) { $array=explode("|",$cookie_string); foreach ($array as $i=>$stuff) { $stuff=explode("=",$stuff); $array[$stuff[0]]=$stuff[1]; unset($array[$i]); } return $array; } Usage: setcookie("mycookies", build_cookie(

need the right way to setcookie in wordpress

半城伤御伤魂 提交于 2019-12-06 14:59:45
i've been looking the whole day how to setcookies in wordpress. in my way i found out (using the developer toolbar) that the cookie is set but still not working. i have 2 files the first contains the login form redirecting to another page to set the cookie and return to another page to check if it's working. domain which is tested on is like this : blog.mydomain.com. here's the setcookie file : <?php setcookie("user_name","test",time()+3600); ?> and chcking the cookie like this : if(isset($_COOKIE["user_name"])){ echo "cookie exists"; } else{ echo "cookie doesn't exist"; } i've read many

Simple PHP Cookie

此生再无相见时 提交于 2019-12-06 07:58:00
I am experimenting with cookies and i am doing this quick example, <html> <head> <meta charset="UTF-8"> <title>Cookies</title> </head> <body> <!-- Start of FORM --> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"> Username: <input type="text" name="username"><br> <input type="submit" name="submit" value="Submit"> </form> <!-- End of FORM --> <hr> <?php if (isset($_POST['username'] )) { setcookie('username', $_POST['username'], time() + 1000, '/'); if(isset($_COOKIE['username'])){ echo "Hello " . $_COOKIE['username']; unset($_COOKIE['username']); } } ?> </body

Unit testing cookies in PHP

点点圈 提交于 2019-12-06 05:54:32
问题 The default practice for unit testing functionality that relies on session/cookie information is to use an abstraction library. But what if I want to write and unit test this abstraction library? The documentation for the PHP setcookiefunction says that the cookie will be available on the next request. Using a command line tool for testing, there is no such thing as a "request". So how can I unit test the correct cookie settings? I want to test if all the parameters of the setcookie function

How to set different cookies for different instances of Chromium embedded browser

和自甴很熟 提交于 2019-12-06 05:11:58
问题 I'm working on an application that requires multiple embedded instances and each of this instance logins to the same external site with different authentication details. I'm using CEF (Chromium embedded framework ) in Delphi , I have a folder that i stored the cookies on it for different instance of my browsers , So i have this code in the first unit procedure TForm2.Button1Click(Sender: TObject); begin form33 := Tform3.Create(nil); form33.Show; end; when the form33 created procedure TForm3

My cookies are only available on PHP pages they are set on, is this normal?

故事扮演 提交于 2019-12-06 01:30:06
问题 I cannot access cookies from any page other than the page they are set on. I looked at print_r($_COOKIE) on different pages and the only common variable between pages is the $_COOKIE['PHPSESSID'] . I am developing on a local XAMPP testing server. Is there a setting I should change on the PHP.ini or is this normal behavior for cookies? Sorry, I'm a little new to this stuff and I was under the impression cookies were accessible site wide. I am setting cookies like: setcookie("user", "Dave