O
O
Oleg Pariyev2020-11-17 21:35:13
C++ / C#
Oleg Pariyev, 2020-11-17 21:35:13

how to get cookie in python?

I'm trying to make a site in python without using any frameworks (argued with friends). The site has a theme change, which is implemented through a cookie.

How to get these same cookies for the right user? That is, those that were saved for this user during the last visit?

It's just that through requests an empty list is returned instead of the data that is needed.

Thanks in advance)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
abcd0x00, 2016-08-31
@abcd0x00

#include <iostream>

using namespace std;

struct package {
    int status;
    unsigned char data[20];
};

int main()
{
    package pkg = { 0, { 0x01, 0x02, 0x03 } };

    cout << pkg.status << int(pkg.data[0]) << endl;
    return 0;
}

T
Therapyx, 2016-08-31
@Therapyx

why? If you have an array and it must be filled with certain constants, then it's better to do it through a vector. Especially if it is not defined how many of them should be. It would make more sense to use something like this:

struct package {
 int status = 1;
vector <byte> data;
}
int main(){
byte arr = {0x01, 0x02, 0x03};
 package pkg;
 for (byte u : arr) {
 pkg.data.push_back(u)
}
}

thus, array blanks will fill the container in the string.
then display on screen
for (auto a : pkg.data) {
  cout << a << endl;
}

I made a mistake somewhere)) I didn’t compile ... It’s better not to use such an approach as you have.

A
Art005, 2020-11-17
@Art005

Cookies are sent by the browser itself in the headers each time it accesses the server.
And you can get from the request by parsing the request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question