I want to add custom user home pages to a site. Basically when a user logs in they will be redirected to their home page that has a series of MySQL queries that display their data. I'd imagine this sort if thing is handled through the assignment of cookies. Can some one point me to a tutorial or script that could help me with this?
http://it2.php.net/manual/en/function.setcookie.php then use header to redirect to the correct page or use javascript.
In addition, you can create sessions instead, or a mix of cookies and session because not all browser support cookies or users have disabled the feature. Further reading on the above tutorial will explain you how to achieve this.
Is one (cookies and sessions) more secure/desirable over the other? Or should I use a combination of the two?
Sessions timeout when the use leaves the page, cookies can be set not to expire for a very long time.
So basically a combination of the two would be preferred? If the site was based entirely on sessions the users would have to log back in every time they left their home page, correct?
i wouldn't say so. the answer as usual is 'it depends'. if you're creating a site where security is important (e.g. banking), you don't want to used things like cookie where the user stays logged in aven though the browser is closed. but if you're creating a site where security is not that important and your visitors are repeat visitors, using a cookie is favourable - e.g. this forum where users leave the cookie alive so that they do not have to log in everytime they visit. personally, i'd prefer using sessions...
It really depends on the site, some sites use both because they secure their admin area with sessions and normal users get cookies.
This isn't for anything as secure as a banking site. It is for something similar in nature to myspace where a user logs in and they are presented with a custom home page based on their info in the DB.