Cookies vs session id parameter in the url

Started on the old forum in January 2018 · view the original in the archive · old links redirect here

4 replies · 108 views · started 8 years ago · 1 min read

2 participants
tupac Developer · 95 posts #1

Which is better and safer and why? storing session id in cookie or having the parameter disclosed in the url ?

something else Fellow · 2,296 posts #2

Having it in the url is a bad idea as they are passed to other sites via referrer when a user clicks an external link on your site. (Unless they have an outgoing page with no session on it). They can be easily stolen and also can be easily socially engineered .

However if you are swapping from url sessions to $_SESSION or $_COOKIE then you need to make sure you secure your script, as you can cause even worse security problems than you had originally had.

tupac Developer · 95 posts #3

when setting cookie, using the http only option as true would help to reduce xxs attacks correct? or is it not necessary?

something else Fellow · 2,296 posts #4

Yeah it helps. Make sure you are also protected from CSRF attacks when using cookies.

tupac Developer · 95 posts #5

And that can be done by implementing a unique hidden token that would only authenticate the real user.

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close