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

  • SEARCH
  • Home
  • 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 8703723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:56:01+00:00 2026-06-13T02:56:01+00:00

I have a project which using a a REST API. Here when Isend a

  • 0

I have a project which using a a REST API. Here when Isend a login request, they are sending me the response as JSON containg some data. Along with that in Response Header

Access-Control-Allow-Origin:*
Connection:keep-alive
Content-Length:239
Content-Type:application/json
Date:Fri, 19 Oct 2012 06:28:12 GMT
Server:Apache/2.2.22 (Amazon)
Set-Cookie:session=username; Path=/

Here we have a Set-Cookie , but this cookie is not setting. I need this cookie to be setted, because for any other API access, the server will check for this cookie.

How can I resolve this Issue? What is the solution for jQuery AJAX response Header Set-Cookie method?

  • 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-13T02:56:04+00:00Added an answer on June 13, 2026 at 2:56 am

    You can get headers from XMLHTTPRequest. This may help. Let me know if this is working.

    $.ajax({
       type: 'POST',
       url:'url.do',
       data: formData,
       success: function(data, textStatus, XMLHttpRequest){
            var cookietoSet=XMLHttpRequest.getResponseHeader('Set-Cookie');
    
            Set_Cookie(cookietoSet.split('=')[0],cookietoSet.split('=')[1],expires, path, domain, secure)//change as per ur needs
       }
       error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest.getResponseHeader('some_header'));
       }
      });
    
    
    
    
    function Set_Cookie( name, value, expires, path, domain, secure )
    {
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime( today.getTime() );
    
    /*
    if the expires variable is set, make the correct
    expires time, the current script below will set
    it for x number of days, to make it for hours,
    delete * 24, for minutes, delete * 60 * 24
    */
    if ( expires )
    {
    expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );
    
    document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have C# project in which I am using Microsoft.SqlServer.Management.Smo, Microsoft.SqlServer.batchparser.dll and few other
I have just restarted a project in which I am using NHibernate. The project
I have a MVC3 ASP.NET Project in which I am using jQuery and KendoUI
I have a postgresql database and am using it for a project which handles
I have two project, one which generates some artifacts from a WSDL file using
I have a legacy project using Rails 2.3.5 but I can't find with which
I have developed a web project. Which is generating log file using log4j. But
I have a simple WCF4 REST service which is working fine when using a
I have constructed a simple Rest service using ServiceStack (which is brilliant), that returns
I have an ASP.NET MVC4 website implementing a REST API, which I'm consuming 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.