setcookie

xmlhttprequest and set-cookie & cookie

折月煮酒 提交于 2019-12-17 15:58:11
问题 i think i misunderstood the management of cookies with xmlhttprequest. I have a server that response to the XMLHttpRequest made in javascript, my server returns Allow-Control-Access-Origin , Access-Control-Allow-Headers , Access-Control-Expose-Headers and Access-Control-Allow-Credentials headers with the correct value. I'm doing a Digest Authenticate in a server with javascript, no problem in that, i receive ok the WWW-Authenticate header from server, i process and send to the server the

Check if a PHP cookie exists and if not set its value

不打扰是莪最后的温柔 提交于 2019-12-17 15:38:03
问题 I am working on a multilingual site so I tried this approach: echo $_COOKIE["lg"]; if (!isset($_COOKIE["lg"])) setcookie("lg", "ro"); echo $_COOKIE["lg"]; The idea is that if the client doesn't have an lg cookie (it is, therefore, the first time they've visited this site) then set a cookie lg = ro for that user. Everything works fine except that if I enter this page for the first time, the first and second echo return nothing. Only if I refresh the page is the cookie set and then both echo

Set cookie on multiple domains with PHP or JavaScript

倾然丶 夕夏残阳落幕 提交于 2019-12-17 10:43:04
问题 I have 3 domains that are themed the same. If somebody chooses a different theme, I want it to propagate across all 3 domains so their experience stays the same. I was planning to accomplish this by setting a cookie on domain1, redirect to domain2 where the cookie is set, redirect to domain3 where the cookie is set, redirect back. Since the information doesn't need to be secure or protected, this will work fine with no real problems. I hate the idea 3 redirects just to set a cookie on each

Python- bottle - cookies keep changing

牧云@^-^@ 提交于 2019-12-14 04:18:25
问题 Below is my code for setting and reading cookies in bottle. if request.get_cookie('mycookiename'): cookie_id = request.get_cookie('mycookiename') else: cookie_id=str(uuid4()) response.set_cookie('mycookiename', cookie_id , max_age=31556952*2, domain='%s' % (cookie_domain)) When I go to firefox and firebug, I can see that the cookie is set. But, when I refresh the page, I get a new cookie. Every request is a new cookie id. So, how do I resolve? 回答1: This code works. You set a new value cookie

Codeigniter 2.1 $this->input->set_cookie($some_var); NOT WORKING

时间秒杀一切 提交于 2019-12-14 01:24:55
问题 I started creating a custom library that i would load for checking if user is logged in and also for registering users. Registration not started yet, but that's not important... here's the problematic part.. it WON't set cookies: $this->load->helper('cookie'); $some_value= 'asd'; $some_cookie_array = array( 'name' => 'some_name', 'value' => $some_value, 'expire' => 86500, 'secure' => TRUE ); $this->input->set_cookie($some_cookie_array); here is the full code for now: codepad.org/FILlq2qR This

Can't set cookie inside construct in codeigniter

谁说胖子不能爱 提交于 2019-12-13 04:05:55
问题 I trying to set a cookie if null but I can't get it to work: public function __construct() { parent::__construct(); if ($this->input->cookie('ff', TRUE) == FALSE) { $this->input->set_cookie('ff', 'on', 86500); dump($this->input->cookie('ff', TRUE)); } } What am I doing wrong? Edit: dump() it's just a custom debug function. 回答1: A couple of reasons your set_cookie call might fail: 1) You've output something to the browser already when set_cookie is called, in which case you might get an error

document.cookie/setCookie not working on Safari and IE

允我心安 提交于 2019-12-13 00:45:44
问题 I am trying to play music from last end point after each page is loaded. This example not working on Safari and IE but working fine on firefox,opera and chrome. Is possible to replace this with jquery cookie plugin and how? <audio preload="auto" src="a.mp3" loop="true" autobuffer autoplay="true"> Unsupported in Firefox </audio> <script> function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" :

Why no `Set-Cookie` headers in response?

浪子不回头ぞ 提交于 2019-12-12 21:09:40
问题 I found sometimes browser can't get cookies from my website, so I use curl to check the headers, and the information is: C:\Documents and Settings\jack>curl http://localhost -I HTTP/1.1 200 OK Expires: Thu, 01-Jan-1970 00:00:00 GMT Set-Cookie: SCALAEYE_SESSION="a57cf8ebdfc379da91ad17d1d1eac706c25ae4c3-%3Citems%3E%3C%2Fitems%3E";Path=/ Set-Cookie: SCALAEYE_FLASH="%3Citems%3E%3C%2Fitems%3E";Path=/ Content-Length: 121665 Server: Jetty(6.1.26) But when I use browsers IE6 and Firefox to visit, the

setcookie not working wordpress because of header

倾然丶 夕夏残阳落幕 提交于 2019-12-12 20:20:01
问题 I have a WordPress plugin that wants to create cookies but it doesn't work. I would really appreciate a help. add_shortcode( 'watchlist', 'cwatchlist_short' ); function cwatchlist_short() { echo '<div class="wrap"><center>'; echo "<form method='POST' action=''"; echo '<p>Please enter the initial of the cryptocurrency or the symbol you want to add to the watchlist!</p> <p>For example: BTC</p>'; echo "<p><input type='text' name='symbol' placeholder='Initials or symbol'>"; echo "<p><input type=

How to set a cookie in jquery using toggle()

好久不见. 提交于 2019-12-12 11:42:22
问题 Looking for a cookie to be set when the user clicks on the link it'll open the div then the user can refresh the page and see the div is still open. =======HTML======= <a class="show-settings" href="#"></a> ========jQuery======= $(function () { //Toggle Settings var s = $("a.show-settings"); //On click to toggle settings s.click(function () { $("#s4-ribbonrow, #s4-titlerow").toggle(); }); //Add/Remove text s.toggle(function () { //$(this).text("Hide Settings"); }, function () { //$(this).text