http-session
Version, currently master branch1 version
- master branchlatestOct 10, 2024
github.com/straight-shoota/http-session
Type-safe sessions for `HTTP::Server`
Installation
# Add this to your shard.yml
dependencies:
http-session:
github: straight-shoota/http-session
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
>= 0.36.1- License
- Apache-2.0
- Author
- Johannes Müller
Dependencies
This version declares no dependencies.
README
http-session
This shard provides type-safe sessions for HTTP::Server.
Installation
-
Add the dependency to your
shard.yml:dependencies: http-session: github: straight-shoota/http-session -
Run
shards install
Usage
The basic tool for session management is HTTPSession::Manager.
The session manager uses a HTTPSession::Storage backend for storage.
Currently available implementations:
HTTPSession::Storage::Memory: In-memory storage. Won't persist beyond server restarts.
Example
require "http-session"
storage = HTTPSession::Storage::Memory(Int32).new
sessions = HTTPSession::Manager.new(storage)
server = HTTP::Server.new([HTTP::LogHandler.new, HTTP::ErrorHandler.new]) do |context|
if context.request.path == "/"
counter = sessions.get(context) || 0
counter += 1
sessions.set(context, counter)
context.response.puts counter
else
context.response.respond_with_status :not_found
end
end
address = server.bind_tcp 0
puts "Listening on http://#{address}"
server.listen
More examples can be found in examples/.
Security
This shard follows the guidelines from the OWASP Session Management Cheat Sheet in order to apply best practices for effective threat control.
Contributing
- Fork it (https://github.com/straight-shoota/http-session/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Johannes Müller - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Oct 10, 2024
- Crystal
>= 0.36.1- Indexed
- yes
Dependents
Repository
github.com/straight-shoota/http-session
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 13, 2026
- Synced
- Aug 13, 2026
- Versions
- 1