简体   繁体   中英

Session variables and RESTful api

We are in the process of gradually implementing REST services for our web application. Currently, the application is in old procedural style type app.

The new app will be in html5 with back end implemented in CF10 REST api calls to cfc`s returning JSON formatted objects.

We need to pass SESSION variables to the REST cfc's through jquery calls. Is there way to avoid putting SESSION variables as arguments to jquery calls? All the REST cfc's are located in the web root of Coldfusion10 so, SESSION scope is not accessible to REST cfc's.

Thanks

I found the following documentation about RESTful services in ColdFusion . See bullet 4 in particular:

REST architectural principles:

A REST-based application follows some architectural principles:

  1. Resource identification : In REST-based architecture everything is a resource. You must identify each of these resources with an URI. In ColdFusion, you can make the functions you define in a CFC available as REST resources and you can access them using an URI.
  2. Uniform and constrained interface : Every resource in a RESTful application should support HTTP common operations ie the resources should be able to handle HTTP protocol methods – GET , PUT , POST and DELETE . In ColdFusion, you can access the resources (functions) via HTTP; each of these resources supports HTTP verbs. Depending on the verb specified in the request, the corresponding resource is invoked.
  3. Representation oriented : REST allows resources to have different representation – plain, HTML, XML, JSON, and so forth. A client can request a specific representation via the HTTP protocol. HTTP provides a simple content-type negotiation protocol between the client and the server. For example, an AJAX application may need data in JSON format, where as a Java application may need it in XML format.
  4. Stateless communication : In REST, the server doesn't store the client session data. However, many techniques exist to exchange state information such as URI rewriting, cookies, and hidden form fields. Also, for encryption, you can use REST on top of HTTPS.

Also found these discussions about it here on StackOverflow:

Way to maintain a session in a REST application

Website based on REST in ColdFusion

maintaining session in REST web service

Do sessions really violate RESTfulness?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM