未在浏览器中设置Cookie

时间:2020-02-12 19:01:17

标签: reactjs cookies request axios

在这个问题上待了一段时间,感谢任何帮助。

此问题与登录请求有关。

我正在通过axios向服务器发出POST请求,从理论上讲,会话ID和csrf令牌应保存在cookie中。但是在应用程序/存储/ Cookie(谷歌浏览器)中没有cookie。

using System;
using System.Text.RegularExpressions;

namespace calendar
{
    class Program
    {
        static void Main()
        {
            int year;
            int day;
            string[] month = new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
            int[] days = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

            Console.Write("Enter the year for which you wish to generate the calendar >> ");
            int.TryParse(Console.ReadLine(), out year); // Validate //

            Console.Write("Enter the day of the week that January first is on >> ");
            int.TryParse(Console.ReadLine(), out day); // Validate //
            while (day > 31 || day < 1) // Reprompt for value if date is out of range //
            {
                Console.WriteLine("Enter a valid date >> ");
                Console.Write("Enter the day of the week that January first is on >> ");
                int.TryParse(Console.ReadLine(), out day); // Validate //

            }

            switch (LeapYear(year)) // Switch statement checks if Leap Year is true //
            {
                case true:
                    days[1] += 1;
                    Console.WriteLine("Calendar for year - {0}", year);
                    for (int i = 0; i < month.Length; i++)   
                    {
                        Console.WriteLine("\n" + month[i]);
                        day = DisplayCalender(days[i], day);
                        Console.Write("\n");

                    }
                    break; 
            }
        }


            public static int DisplayCalender(int days, int start) //Display Function//
        {
            int startDay = start;

            Console.WriteLine("Sun\tMon\tTue\tWed\tThu\tFri\tSat");
            for (int i = 0; i < start; i++)
                Console.Write("\t");
            for (int i = 1; i <= days; i++)
            {
                if (startDay > 6)
                {
                    startDay = 0;
                    Console.WriteLine();
                }
                Console.Write(i + "\t");
                startDay++;
            }

            return startDay;

        }
        public static Boolean LeapYear(int year)
        {
            if ((year % 400 == 0) || ((year % 4 == 0) && !(year % 100 == 0))) // Checks each OR AND statements and return true or false //
            {
                return true;
            }
            else
                return false;
            }

        }
    }

此外,当我发送请求时,我会在devtool标签“网络”中得到此cookie作为响应 SCREENSHOT

在Mozilla Firefox和Microsoft Edge中存在相同的问题。 Cookie不存储。

希望你会帮助我。

0 个答案:

没有答案