On Thursday, 9 April 2015 at 11:45:31 UTC, tcak wrote:
I have written a function as follows:
public bool setCookie(
string name,
string value,
long maxAgeInSeconds = long.min,
string expiresOnGMTDate=null,
string path=null,
string domain=null,
bool secure=false
) shared{
// if headers are sent already, leave
if( headersSent ) return false;
// name cannot be empty
if( (name is null) || (name.length <= 0) ) return false;
writeln(
"Name: ", name,
" Max Age: ", maxAgeInSeconds,
" Expires null: ", (expiresOnGMTDate == null),
" Path equals null: ", (path == null),
" Domain null: ", (domain is null)
);
return true;
}
Here is the testing code:
responseObject.setCookie( "A", "B" );
auto now = std.datetime.Clock.currTime().toSimpleString();
//writeln("Now |", now, "|");
responseObject.setCookie( "Response Time", now );
Here is the results:
Name: A Max Age: -9223372036854775808 Expires null: true
Path equals null: true Domain null: true
Name: Response Time Max Age: -9223372036854775808 Expires
null: true Path equals null: false Domain null: false
I don't know what is happening though, somehow path and domain
parameters in second use of function are not null even I
haven't given any value to them.
If I uncomment the "writeln" line in test code, it turns
normal. I am so much confused right now. What is happening here?
Well, I have tried same code without objects in a test code, and
it is null now as expected. Completely same code though.