$ilovephp Posted April 14, 2010 Share Posted April 14, 2010 Hi fellow PHP Freaks. I am Jayson, 20 years old and I am new to PHP. My question more about the PHP Session. I am aware of the difference of the Cookies and Session, that cookies are stored in the client side and session on the server side. In cookies, it easy to distinguish users since it is managed or stored in the client side, however, in session it is stored in the server side. If so, how do we determine these data stored by session belongs to a particular user? Can we store session ids? I hope my problem was delivered clearly. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/198479-session-vs-cookies-need-help/ Share on other sites More sharing options...
oni-kun Posted April 14, 2010 Share Posted April 14, 2010 The accessable session is just a superglobal array. You can access it like so: session_start(); $_SESSION['key'] = $value; $_SESSION[1][2] = "Value"; If you're calling session_start() (thus starting the session) it will send a cookie to the user with the PHP Session ID. Using cookies is very much the same thing, but is obviously prone to being viewed by users, so it is best to store information in sessions that should be used in-application, such as data retrieved/or to be sent to the database. Cookies or sessions are just your preferrence. Quote Link to comment https://forums.phpfreaks.com/topic/198479-session-vs-cookies-need-help/#findComment-1041483 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.