BotanSS/net/components/Cookie.js

44 lines
812 B
JavaScript
Raw Normal View History

2015-07-23 09:15:24 +00:00
var cl = global.botanLoader;
2015-04-15 10:38:44 +00:00
2015-07-23 09:15:24 +00:00
var util = require( "util" );
2015-04-15 04:17:21 +00:00
2015-07-23 09:15:24 +00:00
var WebParam = cl.load( "botanss.utils.WebParam" );
2015-04-15 04:17:21 +00:00
var Cookie = function( cookieStr, HTTP )
{
2015-07-23 09:15:24 +00:00
WebParam.call( this, cookieStr );
2015-04-15 04:17:21 +00:00
this.HTTP = HTTP;
};
2015-07-23 09:15:24 +00:00
util.inherits( Cookie, WebParam );
2015-04-15 04:17:21 +00:00
Cookie.prototype.seth = function( name, value )
{
this.set( name, value );
this.HTTP.response.headers[ "Set-Cookie" ] = this.toString();
};
Cookie.prototype.toString = function()
{
2015-07-23 09:15:24 +00:00
var cookieStr = "";
var p = "";
var e = "";
for( var i in this.param )
{
switch( i.toLowerCase() )
{
case "path":
p = this.param[i];
continue;
case "expires":
e = this.param[i];
continue;
}
cookieStr += i + "=" + this.param[i] + ";";
}
cookieStr += "Path=" + p + ";" + " Expires=" + e + ";";
return cookieStr;
2015-04-15 04:17:21 +00:00
};
module.exports = Cookie;