Skip to content

Instantly share code, notes, and snippets.

@ta264
Last active August 29, 2015 14:26
Show Gist options
  • Save ta264/7822b1424f72e5b4c961 to your computer and use it in GitHub Desktop.
Save ta264/7822b1424f72e5b4c961 to your computer and use it in GitHub Desktop.
Cookie expiry test
tom@htpc:~/repos/tlstest$ mono utc2.exe
Expires: 02/08/2015 15:19:50 (expired? True)
Expires: 02/08/2015 16:19:50 (expired? False)
using System;
using System.IO;
using System.Net;
public class UtcTest {
public static void Main (string[] args) {
TestExpired(DateTime.UtcNow.AddHours(1));
TestExpired(DateTime.Now.AddHours(1));
return;
}
private static void TestExpired(DateTime expiry) {
var cookie = new Cookie("my", "test", "/", "httpbin.eu");
cookie.Expires = expiry;
Console.WriteLine("Expires: {0} (expired? {1})",
cookie.Expires, cookie.Expired);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment