npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cookie-handle

v1.0.3

Published

同时兼容node和NodeAsp的cookie操作。

Downloads

3

Readme

cookie

同时兼容node和NodeAsp的cookie操作。

使用说明

在node环境中, 作为express中间件使用。

注: 也可以直接使用cookie-parser中间件, 这两者的主要功能是兼容的。

var express = require('express');
var cookieHandle = require('cookie-handle');
var app = express();
app.use(cookieHandle());

在asp环境中, 因为不需要使用express, 所以需要在http请求处理方法中直接传入req, res这两个参数。

var http = require('http');
var cookieHandle = require('cookie-handle');

http.createServer(function(req, res){
    cookieHandle(req, res);
});

读取cookie

req.cookies[key]

写入cookie

res.cookie(key, value, options)

其中, options可用参数如下:

  • domain:cookie在什么域名下有效,类型为String,。默认为网站域名
  • expires: cookie过期时间,类型为Date。如果没有设置或者设置为0,那么该cookie只在这个这个session有效,即关闭浏览器后,这个cookie会被浏览器删除。
  • httpOnly: 只能被web server访问,类型Boolean。默认为false
  • maxAge: 实现expires的功能,设置cookie过期的时间,类型为String,指明从现在开始,多少毫秒以后,cookie到期。
  • path: cookie在什么路径下有效,默认为'/',类型为String
  • secure:只能被HTTPS使用,类型Boolean,默认为false

删除cookie

res.clearCookie(key, options)