Assigning Cookies and User Homepages

Discussion in 'PHP' started by jawinn, Nov 19, 2006.

  1. #1
    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?
     
    jawinn, Nov 19, 2006 IP
  2. missenlinx

    missenlinx Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    http://it2.php.net/manual/en/function.setcookie.php

    then use header to redirect to the correct page or use javascript.
     
    missenlinx, Nov 19, 2006 IP
  3. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    Pat Gael, Nov 19, 2006 IP
  4. jawinn

    jawinn Active Member

    Messages:
    1,024
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    88
    #4
    Is one (cookies and sessions) more secure/desirable over the other? Or should I use a combination of the two?
     
    jawinn, Nov 20, 2006 IP
  5. crazybjörn

    crazybjörn Peon

    Messages:
    270
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sessions timeout when the use leaves the page, cookies can be set not to expire for a very long time.
     
    crazybjörn, Nov 20, 2006 IP
  6. jawinn

    jawinn Active Member

    Messages:
    1,024
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    88
    #6
    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?
     
    jawinn, Nov 20, 2006 IP
  7. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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...
     
    daboss, Nov 20, 2006 IP
  8. crazybjörn

    crazybjörn Peon

    Messages:
    270
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #8
    It really depends on the site, some sites use both because they secure their admin area with sessions and normal users get cookies.
     
    crazybjörn, Nov 20, 2006 IP
  9. jawinn

    jawinn Active Member

    Messages:
    1,024
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    88
    #9
    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.
     
    jawinn, Nov 20, 2006 IP
  10. crazybjörn

    crazybjörn Peon

    Messages:
    270
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Cookies will be fine for that. Especially if you want the site to remember the users.
     
    crazybjörn, Nov 20, 2006 IP