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 334255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:02:14+00:00 2026-05-12T10:02:14+00:00

I’ve inherited a rather convoluted project. The original designer created a cookie that appears

  • 0

I’ve inherited a rather convoluted project. The original designer created a “cookie” that appears to be server side rather than client based (though I could be very wrong on that part). He is using it for what he called “Least Privileges, Single Sign On”. I have the following code in all of the Web Service Proxies he set up:

[WebServiceBinding(Name = "ISecurityManager", Namespace = "urn:riv:apis:security:forms:ver1")]
public partial class SecurityManager : SoapHttpClientProtocol, ISecurityManager
{
    public SecurityManager()
    {
        //Url = CookieManager.WebServiceUrl(String.Empty, ref CookieContainer);
        // I’d like to replace the following code with a call like this...

        CookieContainer = new System.Net.CookieContainer();
        string urlSetting = ConfigurationManager.AppSettings["SecurityManager"];

        if (urlSetting != null)
            Url = urlSetting;
        else
            Trace.TraceWarning("No URL was found in application configuration file");

        string cookieName = FormsAuthentication.FormsCookieName;
        string cookiePath = FormsAuthentication.FormsCookiePath;
        string cookieDomain = Properties.Settings.Default.CookieDomain;
        HttpCookie authCookie = HttpContext.Current.Request.Cookies[cookieName];

        if (null != authCookie)
            CookieContainer.Add(new Uri(urlSetting), new System.Net.Cookie(cookieName, authCookie.Value, cookiePath, cookieDomain));
    }
….

I also have this code pretty much everywhere:

string cookieName = FormsAuthentication.FormsCookieName;
string SecurityContext.ApplicationName = HttpContext.Current.Request.Cookies[cookieName].Path;
string SecurityContext.UserName = HttpContext.Current.User.Identity.Name;

if (!string.IsNullOrEmpty(SecurityContext.UserName))
….

In all instances, when it goes to get the authCookie, it comes up null or the SecurityContext.UserName is blank. I’m not a cookie guru and a lot of this guy’s code is obfuscated – and zero documentation.

Can anyone make heads or tails out of the intent of the code blocks?

TIA

  • 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-05-12T10:02:14+00:00Added an answer on May 12, 2026 at 10:02 am

    FormsAuthentication for a web service method? Storing authentication credentials in a cookie? There are so many things wrong with this story. (Note: heavy obfuscation of code should be taken as a sign.)

    The intent of the code blocks, as it appears, is using the cookie framework for user identification during a method call. It assumes the user has already been authenticated and that the authentication cookie is present in all requests.


    EDIT: a bit more information on “server-side cookies” — the references you see to System.Net.Cookie and such are .Net Framework classes for handling cookies. Cookies are client-side pieces of data that reside either in-memory for the client (usually a web browser), and/or saved as text files somewhere on the local file system of the client. Most web applications that set client-side cookies assume they are dealing with a web browser, as all the major browser providers support cookies.

    When a web browser is used to make a request to a URL, lots of information is sent in the background that is hidden from the user: IP address, the type of browser and OS, etc. Included in this list are cookies for that given URL domain (there are HTTP rules that browsers agree to). The code you’re looking at are specific .Net Framework classes for dealing with those cookie values in a structured way.


    Most applications that consume web services are completely stateless — no cookies, no sessions, nothing. While it’s possible that a client to a web service may implement cookie support, assuming or requiring cookie support for a web service is folly.

    In the code scenario you’ve debugged to detect null values, most likely the calling application does not support cookies, effectively rendering the entire code block invalid. This is broken-by-design.

    I cannot find a sensible way of improving this code block that doesn’t involve a teardown of the entire structure. Given your suggested level of familiarity, spend a little time on web security 101. Get familiar with the concepts of authentication, sessions, (and cookies, too.) You’ll know you’re ready to proceed as soon as you realize that security is something you don’t invent yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've inherited a rather large application that really could use some cleanup. There is
We've inherited a rather large Access DB that has some very strange (and unsettling)
I've inherited some rather large static HTML files that need to be fixed up
I've inherited a rather large WPF application, and I need to generate application traces
I've inherited a rather large and somewhat messy codebase, and have been tasked with
Are there any programs that will allow you to follow a sql transaction through
If I have these two classes: class A {} class B : A {}
I have been reading up on porting ASP.NET Membership Provider into .NET 3.5 using
The library I'm using has class G and class S which inherits G. I

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.