8000 Add a version prefix to the private id to make easier to migrate old … · rack/rack@5b1cab6 · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 5b1cab6

Browse files
rafaelfrancatenderlove
authored andcommitted
Add a version prefix to the private id to make easier to migrate old values
1 parent 1e96e0f commit 5b1cab6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/rack/session/abstract/id.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ module Rack
1313
module Session
1414

1515
class SessionId
16+
ID_VERSION = 2
17+
1618
attr_reader :public_id
1719

1820
def initialize(public_id)
1921
@public_id = public_id
2022
end
2123

2224
def private_id
23-
hash_sid public_id
25+
"#{ID_VERSION}::#{hash_sid(public_id)}"
2426
end
2527

2628
alias :cookie_value :public_id

test/spec_session_memcache.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@
246246
pool.pool.set(session_id.public_id, ses0, 0, true)
247247
pool.pool.delete(session_id.private_id)
248248

249-
250249
res1 = req.get("/", "HTTP_COOKIE" => cookie)
251250
res1["Set-Cookie"].must_be_nil
252251
res1.body.must_equal '{"counter"=>2}'
@@ -266,7 +265,6 @@
266265
pool.pool.set(session_id.public_id, ses0, 0, true)
267266
pool.pool.delete(session_id.private_id)
268267

269-
270268
res2 = dreq.get("/", "HTTP_COOKIE" => cookie)
271269
res2["Set-Cookie"].must_be_nil
272270
res2.body.must_equal '{"counter"=>2}'

0 commit comments

Comments
 (0)
0