Persistent Cookie isn't being found The Next CEO of Stack OverflowCookies and ObjectsHow do I set/unset a cookie with jQuery?Local Storage vs CookiesAndroid HttpClient persistent cookiessetting persistent cookies with javascriptRemember me Persistent Cookie in C#ASP.NET_SessionId + OWIN Cookies do not send to browserasp.net mvc 5 cookies not persisting on local serverPersistent Cookie is not working in cross browser'sread form authentication cookie between websites on same server

How do I reset passwords on multiple websites easily?

How to safely derail a train during transit?

Interfacing a button to MCU (and PC) with 50m long cable

Anatomically Correct Strange Women In Ponds Distributing Swords

Return the Closest Prime Number

How do I make a variable always equal to the result of some calculations?

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Elegant way to replace substring in a regex with optional groups in Python?

What was the first Unix version to run on a microcomputer?

Is 'diverse range' a pleonastic phrase?

Several mode to write the symbol of a vector

To not tell, not take, and not want

If/When UK leaves the EU, can a future goverment conduct a referendum to join the EU?

What flight has the highest ratio of time difference to flight time?

Can you replace a racial trait cantrip when leveling up?

Why am I allowed to create multiple unique pointers from a single object?

Which tube will fit a -(700 x 25c) wheel?

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Is it ever safe to open a suspicious html file (e.g. email attachment)?

How do I transpose the 1st and -1th levels of an arbitrarily nested array?

Which kind of appliances can one connect to electric sockets located in a airplane's toilet?

What happened in Rome, when the western empire "fell"?

What's the best way to handle refactoring a big file?

Are there any unintended negative consequences to allowing PCs to gain multiple levels at once in a short milestone-XP game?



Persistent Cookie isn't being found



The Next CEO of Stack OverflowCookies and ObjectsHow do I set/unset a cookie with jQuery?Local Storage vs CookiesAndroid HttpClient persistent cookiessetting persistent cookies with javascriptRemember me Persistent Cookie in C#ASP.NET_SessionId + OWIN Cookies do not send to browserasp.net mvc 5 cookies not persisting on local serverPersistent Cookie is not working in cross browser'sread form authentication cookie between websites on same server










0















I am trying to pass information between two asp.net C# web applications using a persistent cookie. In the first application, I'm creating the cookie like this:



HttpCookie myCookie = new HttpCookie("myCookie");
myCookie.Values["foo"] = "some value";
// repeat for each value added
myCookie.Expires = DateTime.Now.AddHours(1);
Response.Cookies.Add(myCookie);


In my second application, I check for the cookie this way:



if (Request.Cookies["myCookie"] == null)

//gtfo

else

//come on in!



The problem is that when the user arrives at the second application, the cookie often isn't found on the fist try. They can't get to the second application but through the first, and they have to login at the first application, which sets the cookie.



I have tried adding a "if (Request.Cookies["myCookie"] == null)" to the first application to make sure the cookie is set, but this doesn't fix the problem. Checking for "Request.Cookies["myCookie"].Value" instead of "Request.Cookies["myCookie"]" throws an "object reference not set" error.



How can I make sure the cookie is found on the first try?










share|improve this question


























    0















    I am trying to pass information between two asp.net C# web applications using a persistent cookie. In the first application, I'm creating the cookie like this:



    HttpCookie myCookie = new HttpCookie("myCookie");
    myCookie.Values["foo"] = "some value";
    // repeat for each value added
    myCookie.Expires = DateTime.Now.AddHours(1);
    Response.Cookies.Add(myCookie);


    In my second application, I check for the cookie this way:



    if (Request.Cookies["myCookie"] == null)

    //gtfo

    else

    //come on in!



    The problem is that when the user arrives at the second application, the cookie often isn't found on the fist try. They can't get to the second application but through the first, and they have to login at the first application, which sets the cookie.



    I have tried adding a "if (Request.Cookies["myCookie"] == null)" to the first application to make sure the cookie is set, but this doesn't fix the problem. Checking for "Request.Cookies["myCookie"].Value" instead of "Request.Cookies["myCookie"]" throws an "object reference not set" error.



    How can I make sure the cookie is found on the first try?










    share|improve this question
























      0












      0








      0








      I am trying to pass information between two asp.net C# web applications using a persistent cookie. In the first application, I'm creating the cookie like this:



      HttpCookie myCookie = new HttpCookie("myCookie");
      myCookie.Values["foo"] = "some value";
      // repeat for each value added
      myCookie.Expires = DateTime.Now.AddHours(1);
      Response.Cookies.Add(myCookie);


      In my second application, I check for the cookie this way:



      if (Request.Cookies["myCookie"] == null)

      //gtfo

      else

      //come on in!



      The problem is that when the user arrives at the second application, the cookie often isn't found on the fist try. They can't get to the second application but through the first, and they have to login at the first application, which sets the cookie.



      I have tried adding a "if (Request.Cookies["myCookie"] == null)" to the first application to make sure the cookie is set, but this doesn't fix the problem. Checking for "Request.Cookies["myCookie"].Value" instead of "Request.Cookies["myCookie"]" throws an "object reference not set" error.



      How can I make sure the cookie is found on the first try?










      share|improve this question














      I am trying to pass information between two asp.net C# web applications using a persistent cookie. In the first application, I'm creating the cookie like this:



      HttpCookie myCookie = new HttpCookie("myCookie");
      myCookie.Values["foo"] = "some value";
      // repeat for each value added
      myCookie.Expires = DateTime.Now.AddHours(1);
      Response.Cookies.Add(myCookie);


      In my second application, I check for the cookie this way:



      if (Request.Cookies["myCookie"] == null)

      //gtfo

      else

      //come on in!



      The problem is that when the user arrives at the second application, the cookie often isn't found on the fist try. They can't get to the second application but through the first, and they have to login at the first application, which sets the cookie.



      I have tried adding a "if (Request.Cookies["myCookie"] == null)" to the first application to make sure the cookie is set, but this doesn't fix the problem. Checking for "Request.Cookies["myCookie"].Value" instead of "Request.Cookies["myCookie"]" throws an "object reference not set" error.



      How can I make sure the cookie is found on the first try?







      c# asp.net cookies






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 15:18









      Robert MurrellRobert Murrell

      106111




      106111






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047198%2fpersistent-cookie-isnt-being-found%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047198%2fpersistent-cookie-isnt-being-found%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved