Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    This little Earth.
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts

    customized user's personal page using sessions?

    so far in php i've only worked with database interaction and ordinary programming, so i don't know much about sessions, cookies, http_...stuff etc.

    i'm doing a site where registered users get to choose their custom css style for the site, work on language lessons, take tests and exercises, etc. whenever they log in they can go to their own user page and everything here should be customized according to themselves; the site style (colors, etd), a link to the lesson they're currently studying, a link to their past performance, a link to a list of threads they're subscribed to in the site's forum (pretty much like here at CF), a link to .... you get the idea.

    for one thing, i'm not exactly sure what would be right to use, cookies or sessions, or both. by reading previous threads i guess i'll be using sessions.

    but the main problem is how can i go about tracking the user's activity so that i know which page he/she left off on last time, so that when he/she logs in again, there should be a link to that particular page? what i can think of so far is that every page should have a session_start on top and should register the user on it, then when the user closes the browser, the session stores the page he was on that was closed, to get inserted in the database.
    like for eg, if A signs in and goes to page1, the session "username" will be registered with value "A" and variable "curr_page" will also be registered and will update the A's 'curr_page' column in the database. then, when he goes to page2, "curr_page" will change and update the database again. and so on until the user simply disconnects or closes the browser window.
    that's what i can think of so far, no idea if it's the right approach. any suggestions?
    'If you don't stand for something, you'll fall for anything.'

  • #2
    New Coder
    Join Date
    Mar 2003
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here is how i would do it

    i would create a header.php that you include on every page. In this page you would start the sessions, etc etc. You would also have a mysql query that updates the users location into the database so basically it records where the user is going, not where they were before they left. IT gets tricky recording the location AFTER people have left your site :P

    In reguards to "sessions or cookies?" a simple way to look at is:

    cookies are insecure yet last longer. sessions are more secure but dont last as long.

    You could use a combination of the two.

    WOW! i hope that all made sense
    LocalHoster.com
    Your Price. Your Features. Your Hosting™

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You will want to use sessions to keep track of their current progress.

    As for saving where they left off I would include a "Save your progress" button. If they just close the browser there is no way to save what they have done so you should make it known to them that they need to save their work before they leave if they wish to start from where they left off.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    New Coder
    Join Date
    Mar 2003
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i dont think many people would bother clicking the 'save' button

    It should be automatic.
    LocalHoster.com
    Your Price. Your Features. Your Hosting™

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    if every page updates the database then it does not matter if the user closes the browser window without saving.

    Remember all your server-side processing is done well before the user gets to see the page, so if in your scripts you make sure that the last thing you do in your script is save the session data to the database.

    <html>
    //etc
    <?
    //do your stuff//
    ?>
    //etc
    </html>
    <? save_session_data();?>

    if you dont want to crawl through your code adding the function you can utilise .

    PHP Code:
    <?
    function save_session_data(){
      echo 
    "this will be called when all other processing is complete";
    }
    register_shutdown_function("save_session_data");
    //etc//
    ?>
    note that register_shutdown_function() is ropey on windows
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Well once the page has already loaded and then they do some work the data cannot be saved automatically before they close the browser. Another request to the server would have to be made. I've seen other sites where l've filled out long applications and they provide a save feature so you can come back later. They even pop up an alert every few pages to remind you to save your work.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    yes for forms etc , I thought this was just tracking users around the page / and or personalised settings ?

    They even pop up an alert every few pages to remind you to save your work.
    not via a talking paperclip I hope
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by firepages
    yes for forms etc , I thought this was just tracking users around the page / and or personalised settings ?



    not via a talking paperclip I hope
    He had mentioned taking tests and doing exercises and stuff so I would assume the use of forms.

    I hate that talking paperclip dude.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •