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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:34:00+00:00 2026-06-06T03:34:00+00:00

I got this cookie returned from web-server in Set-Cookie header: PHPSESSID=462rutd8g0sbg9sinh3hqa2ol6; path=/,wordpress_test_cookie=WP+Cookie+check; path=/,wordpress_ca07030412dd7fcd4dbeaae0bd9f5df9=testemail@example.com; expires=Sun,

  • 0

I got this cookie returned from web-server in Set-Cookie header:

PHPSESSID=462rutd8g0sbg9sinh3hqa2ol6;
path=/,wordpress_test_cookie=WP+Cookie+check;
path=/,wordpress_ca07030412dd7fcd4dbeaae0bd9f5df9=testemail@example.com;
expires=Sun, 01-Jul-2012 05:11:02 GMT; path=/wp-content/plugins;
httponly,wordpress_ca07030412dd7fcd4dbeaae0bd9f5df9=testemail@example.com;
expires=Sun, 01-Jul-2012 05:11:02 GMT; path=/wp-admin;
httponly,wordpress_logged_in_ca07030412dd7fcd4dbeaae0bd9f5df9=testemail@example.com;
expires=Sun, 01-Jul-2012 05:11:02 GMT; path=/; httponly

I am trying to use CookieContainer.SetCookies(new Uri(url),cookie);

But it throws exception ‘{“An error occurred when parsing the Cookie header for Uri ‘http://www.smallbizads.us/‘.”} System.FormatException {System.Net.CookieException’

Some digging reveals that SetCookies uses , to break up the cookies. But that won’t work obviously because I have Expires header which also has ,

Any idea how can I get around this issue?

Note: I can only use this method by fetching cookie from Set-Cookie header due to WordPress issue. So please do not suggest any other option.

  • 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-06T03:34:02+00:00Added an answer on June 6, 2026 at 3:34 am

    Took me a while to dissect it.

    As far as I can see you want to set the PHPSESSID (PHP Session Id) generated by WordPress for one domain (.smallbizads.us) for several paths. The expiration date is always the same.

    First you take your cookie header:

    string cookieHeader = "PHPSESSID=462rutd8g0sbg9sinh3hqa2ol6; ...etc;"
    

    Split it by the ‘;’ delimiter character.

    var cookies = cookieHeader.Split(new[] {';'}).ToList();
    

    You wind up with a list of 12 items. For example:

    • “PHPSESSID=462rutd8g0sbg9sinh3hqa2ol6”
    • ” path=/,wordpress_test_cookie=WP+Cookie+check”
    • ” expires=Sun, 01-Jul-2012 05:11:02 GMT”
    • …

    The expiration date is shown multiple times in this list, but it always has the same value.
    Just take the first expiration date and convert it to a DateTime.

    var expiresValue = (from c in cookies
                        where c.Trim().StartsWith("expires")
                        select c).First();
    var expiresOn = DateTime.Parse(expiresValue.Substring(expiresValue.IndexOf('=') + 1));
    

    OK, now let’s get the value for the cookie. The session id:

    var sessionId = (from c in cookies
                     where c.Trim().StartsWith("PHPSESSID")
                     select c).Single();
    sessionId = sessionId.Substring(sessionId.IndexOf('=') + 1);
    

    Now get the paths for which you need to set the cookie.

    var paths = (from c in cookies
                 where c.Trim().StartsWith("path=")
                 select c).ToList();
    

    Now you can set the cookies using a CookieContainer and the System.Net.Cookie class.

    foreach (var path in paths)
    {
        var cookie = new Cookie();
        cookie.Name = "PHPSESSID";
        cookie.Value = sessionId;
        cookie.Domain = ".smallbizads.us";
        cookie.Expires = expiresOn;
        cookie.HttpOnly = true;
    
        var container = new CookieContainer();
    
        var startIndex = path.IndexOf('=') + 1;
        var stopIndex = path.Contains(',') ? path.IndexOf(',') : path.Length;
        cookie.Path = path.Substring(startIndex, stopIndex - startIndex);
    
        container.Add(cookie);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my jsp page i have put ${header.cookie} and I got this : JSESSIONID=1bxvxsg61zphc;
Got this site with UN/PW set via the Createuserwizard control. Client considers PW too
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
I got this message when I tried to log off from a site: You
Got it from php.net, but I am not sure is this how everybody destroy
I need to pass some variables from a cookie to jQuery, but I got
I've got a PHP application which needs to grab the contents from another web
Got this line of code here but its not working. private void Button_Click(object sender,
Got this: Table a ID RelatedBs 1 NULL 2 NULL Table b AID ID
Got this error on a big $_GET query in size ~9 000 symbols (they

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.