| |

VerySource

 Forgot password?
 Register
Search
View: 1456|Reply: 3

Can InternetSetCookie be used to set IE cookies in VC programs?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-24 19:00:02
| Show all posts |Read mode
title:
  Can InternetSetCookie be used to set IE cookies in VC programs?

Process and phenomenon:
  (1) User name and password: use CInternetSession and CHttpConnection in wininet.lib to log in successfully.
  (2) Get Cookie: InternetGetCookie( (LPCTSTR)strURL, NULL, szCookie,&dwLength ); The cookie obtained successfully is: ASP.NET_SessionId=xxxxxxx;
  (3) Set Cookie: IInternetSetCookie((LPCTSTR)strURL,NULL,szCookie ); success
  (4) Open IE:ShellExecute( NULL, "open", "IExplore", (LPCTSTR)strURL,NULL, SW_SHOWNORMAL); Always show "Session Expired" warning dialog box, I use HttpWatch to see if there is no (3) Cookies set in.

Questions I want to ask:
   (1) Can the cookie set with IInternetSetCookie be used by IE?
   (2) If so, why can't the above settings work! What is wrong? Where else should I set up?
   (3) Does the above situation have anything to do with HTTP SERVER?

Thanks:
  Would you please give me more advice from experienced friends! Thanks in advance!
Reply

Use magic Report

0

Threads

16

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-24 19:45:01
| Show all posts
What is lz doing?
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-24 20:00:01
| Show all posts
The problem of the original poster is similar to mine. In fact, you made a mistake in the second step. Although you can return 0 with getlasterror, your setting does not take effect. When you use Internetsetcookie, the cookie value cannot be set at all. If you can If you set it, you only need to call Internetsetcookie once in the third step. The first call only creates a temporary, and the second time it creates a real cookie. In fact, you made a mistake in the second step. You can try to copy all the content in the cookie you want to set and delete it, and then set it to the original content. You will find that although getlasterror returns 0, you have not set this value. If you can set it, please post Learn the code together, thank you, the original poster.
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-24 20:15:01
| Show all posts
Wrong is wrong in the third step. I was not optimistic just now
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list