使用Sessions实现REST api好吗? [英] Is it good to implement REST api using Sessions?

查看:89
本文介绍了使用Sessions实现REST api好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

REST客户端通常每次都会发送一个身份验证参数,该参数的作用类似于浏览器中的PHP会话ID cookie.但是REST客户端不是浏览器,因此尽管在服务器端代码中,我为什么不采用该身份验证参数并使用

session_id($_GET('authentication_code'));

这是个好方法吗?

解决方案

答案是否定的. S REST用于 stateless ,这意味着您无法在服务器上存储任何内容./p>

A REST client usually send an authentication parameter every time which acts like PHP Session Id cookie in browser in a way. But REST client is no browser so I though in my server side code why not I take that authentication parameter and use

session_id($_GET('authentication_code'));

Is it good way of doing it ??

解决方案

The answer is no. The S REST is for stateless which means you cannot store anything on the server.

这篇关于使用Sessions实现REST api好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆