/    Sign up×
Community /Pin to ProfileBookmark

Which are safer COOKIES or SESSION

To store things like if logged in settings, user ID and user levels. Whats the best place to store them. Session or cookie?

Session means logging in each visit which a pain for people but other than that is one better than the other?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 15.2021 — Sessions are safer (even though they use cookies). Cookies by themselves can be easily faked. A session cookie is only useful if they guess an active session ID that matches an unexpired set of session data on the PHP server.
Copy linkTweet thisAlerts:
@developer_webNov 19.2021 — @kiwis80#1639414

Use the $_SESSION[''] and add a checkbox "Remember This" for their browsers to remember the user login credentials. That way, they can auto login. Just make sure to add an alert that they should not check the checkbox if they're on a public computer. As in a library or internet cafe.

I'm gonna do this.

Now, go and read tutorials on how to write the "Remember This" feature with php. I have forgotten how to code it. Last I did about half a dacade ago. I too need to read up on it. Revision.

Good ? :)
Copy linkTweet thisAlerts:
@helengreyNov 23.2021 — Session is a way to temporarily store the user information on the server-side, whereas cookies store the information on the user's computer until it expires. I think Sessions are more secure than cookies as it is stored in server. Cookie can be turned off from browser.
Copy linkTweet thisAlerts:
@developer_webNov 23.2021 — User can access the COOKIE since it's on clientside.

User can't access the SESSION since it's on serverside. Now you decide which is safer!
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...