Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8390427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:59:01+00:00 2026-06-09T18:59:01+00:00

I am making an ajax call from an html page (mobile) to a .net

  • 0

I am making an ajax call from an html page (mobile) to a .net server for a login and authentication. Right now i am sending back a JSON response with success:true. This all works fine but I need to set the cookies so that the user is remembered when I make other calls to record data once logged in.

I read about using JSONP, but I would rather not go that route if I don’t have to since it means changing a lot. I would like to just send the cookie back in the response and set it manually on the client side.

How do I retrieve this cookie (or create the cookie?” on the server side in .net and send it back in the response?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:59:03+00:00Added an answer on June 9, 2026 at 6:59 pm

    In your success event of ajax, you can set the cookie in client side

    Assuming your JSON is like this

      {    "success": "true",    "username": "scott"   }
    

    And in your ajax function, check the JSON and if the success item value is true, set the cookie.

    $.ajax({
            url: "someserverpage.aspx",
            success: function(data) {
               if(data.success=="true")
               {
                  SetCookie("YoursiteUsername",data.username,365);                   
               }
            }
    });
    

    The SetCookie function sets the cookie.

    function SetCookie(c_name,value,exdays)
    {
      var exdate=new Date();
      exdate.setDate(exdate.getDate() + exdays);
      var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
      document.cookie=c_name + "=" + c_value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an AJAX call with JQuery and sending up JSON from an MVC
I'm making an ajax call to a server page and print the result in
When making an AJAX call from the client, the server responds with Hebrew text.
I m making an ajax call using jQuery to an ASP.NET page which acts
I am making an ajax call to a server as soon as i enter
I am including a jsp fragment by making an ajax call. Now this jsp
I am making a webservice call that needs and authentication password using jquery ajax.
I'm making a call to another ajax page, the call posts a json object.
I am making an Ajax call within my page to a DB and pulling
Possible Duplicate: how to protect ajaxRequest.open php script im making a ajax call from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.