cookies

ASP.NET Core session authentication

梦想与她 提交于 2021-02-08 08:43:19
问题 I'm developing an ASP.NET Core 2.2 web application. I want to store user claims in application memory, not in cookies. I add AddDistributedMemoryCache , AddSession and UseSession as described here, but when page is requested, I still see cookie data sent to server and received from the server. My Startup class: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the

How to write & print a PHP cookie in the same request?

僤鯓⒐⒋嵵緔 提交于 2021-02-08 08:25:50
问题 I'm not sure why, but the following doesn't seem to work as expected: <?php setcookie('my_cookie', $_GET['v'], time() + (86400 * 7)); echo $_COOKIE['my_cookie']; ?> If you put this in a file on a PHP web server and call it with a query of yourdomain.com/index.php?v=value . The value only gets printed to the page on the 2nd request. Why not on the 1st? 回答1: The $_COOKIE array represents only those cookies that came in the request from the client. setcookie() adds an HTTP header asking the

Android CookieManager getCookie issue

你说的曾经没有我的故事 提交于 2021-02-08 08:20:42
问题 I am setting a cookie using cookiemanager setcookie API, when I do cookiemanager getcookie I am not getting the domain & expiry date below is my code. String cookieString = cookie.getName() + "=" + cookie.getValue() + "; Domain=" + cookie.getDomain()+"; expires=" + cookie.getExpiryDate(); CookieManager.getInstance().setCookie("http://mydomainname.com", cookieString); String cookie = CookieManager.getInstance().getCookie("http://mydomainname.com"); Any idea why cookiemanager getcookie doesn't

Set the XSRF cookie on the client side

谁说胖子不能爱 提交于 2021-02-08 08:13:14
问题 I want to implement a CSRF prevention mechanism for my application by setting a cookie and sending an HTTP header with the same value with every POST / PUT / DELETE request. Everywhere I read, the best practices suggest that the csrf cookie should be set from the server. I'm building a single page app using AngularJS and they also suggest that for security reasons the cookie should be send by the server on the first GET request. My question is - why should the server send the cookie and not

Getting Html.AntiForgeryToken throws error “Server cannot modify cookies after HTTP headers have been sent”

非 Y 不嫁゛ 提交于 2021-02-08 07:34:22
问题 When I attempt to run the following code: <form id="__SendAjaxAntiForgery" action="#" method="post"><%= Html.AntiForgeryToken()%></form> I get the following error "Server cannot modify cookies after HTTP headers have been sent." The stack trace reads at System.Web.HttpResponse.BeforeCookieCollectionChange() at System.Web.HttpCookieCollection.Set(HttpCookie cookie) at System.Web.Helpers.AntiXsrf.AntiForgeryWorker.GetFormInputElement(HttpContextBase httpContext) at System.Web.Helpers

Getting Html.AntiForgeryToken throws error “Server cannot modify cookies after HTTP headers have been sent”

霸气de小男生 提交于 2021-02-08 07:34:19
问题 When I attempt to run the following code: <form id="__SendAjaxAntiForgery" action="#" method="post"><%= Html.AntiForgeryToken()%></form> I get the following error "Server cannot modify cookies after HTTP headers have been sent." The stack trace reads at System.Web.HttpResponse.BeforeCookieCollectionChange() at System.Web.HttpCookieCollection.Set(HttpCookie cookie) at System.Web.Helpers.AntiXsrf.AntiForgeryWorker.GetFormInputElement(HttpContextBase httpContext) at System.Web.Helpers

How does Python's Requests treat multiple cookies in a header

陌路散爱 提交于 2021-02-08 04:51:33
问题 I use Python Rquests to extract full headers of responses. I want to accurately count how many cookies (i.e. nam/variable) pairs in a response. There are two issues: 1) If a server responded with multiple Set-Cookie headers. How does Requests represent this? Does it combine both Set-Cookie values in one? Or leave it as is? Here is my script to print headers (full header): import requests requests.packages.urllib3.disable_warnings() # to disable certificate warnings response = requests.get(

Read in cookie to Shiny application with embedded javascript

孤者浪人 提交于 2021-02-08 04:43:19
问题 I'm getting started with Shiny and loving it. But I've come upon a stumbling point with incorporating javascript in my Shiny applications to add on some additional functionality. Hoping to get some help. Here's a very basic Shiny application I'm using to test the feasibility of reading in a browser cookie with javascript so it can be accessed in ui.R. The ui.R code. # UI file of getCookie Shiny application. shinyUI(fluidPage( titlePanel('Cookie'), cookie <- tags$head(tags$script(src=

How to get more than one Set-Cookie header from response using Retrofit/OkHttpClient?

。_饼干妹妹 提交于 2021-02-08 04:41:43
问题 I'm trying to make an authentication call using Retrofit/OkHttpClient on Android. The server responds a 302 with two Set-Cookie headers and okHttp handles redirection. I found some tips to get those cookies using cookieManager. But it seems cookieManager reads only one Set-Cookie header. I have this in server response headers: Set-Cookie:first=1 Set-Cookie:second=2 This is my cookieManager part: private static CookieManager cookieManager; (...) OkHttpClient okHttpClient = new OkHttpClient();

How to store this data in cookies?

a 夏天 提交于 2021-02-07 22:37:34
问题 Let's say i have some textboxes/textareas of which the values have to be stored. The values have to be stored on key press, so that no data is lost when the user closes the page too early. Here's my current code (using cookies): function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = '; expires=' + date.toGMTString(); } else var expires = ''; document.cookie = name + '=' + value + expires + ';