1***@qq.com
1***@qq.com
  • 发布:2025-02-07 09:16
  • 更新:2025-02-07 09:45
  • 阅读:13

怎么在响应头里设置多个cookie

分类:uniCloud
exports.main = async (event, context) => {  
    //event为客户端上传的参数  
    console.log('event : ', event)  

    //返回数据给客户端  
    return {  
    mpserverlessComposedResponse: true, // 使用阿里云返回集成响应是需要此字段为true  
    isBase64Encoded: false,  
    statusCode: 200,  
    headers: {  
        'set-cookie': 'cookie1=value1',//这种方式只能设置一个cookie  
    },  
        body:'a'  
}  
};
2025-02-07 09:16 负责人:无 分享
已邀请:
靐齉齾麤龖龗

靐齉齾麤龖龗 - 解决不了问题,那就解决提出问题的人

多个之间用;隔开不行吗?

杨杨得亿

杨杨得亿 - 这个人很懒,什么都没有留下~

使用数组形式

exports.main = async (event, context) => {    
    //event为客户端上传的参数    
    console.log('event : ', event)    

    //返回数据给客户端    
    return {    
    mpserverlessComposedResponse: true, // 使用阿里云返回集成响应是需要此字段为true    
    isBase64Encoded: false,    
    statusCode: 200,    
    headers: {    
        'set-cookie': ['cookie1=value1; Max-Age=900; HttpOnly', 'cookie2=value2; Max-Age=900; HttpOnly']  
    },    
        body:'a'    
}    
};

要回复问题请先登录注册