"since your last visit" quandary

This is a discussion on ""since your last visit" quandary" within the PHP Forum section. This forum, and the thread ""since your last visit" quandary are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 21st, 2007, 22:45
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
"since your last visit" quandary

Application is a simple message board. Each time the user returns I want to show a message stating the number of new posts since the last visit. But here's the catch - I want to retain that information for the user's entire session, only updating the "LastPost" datum at the end of the session.

Now, Determining which posts are new and storing the "LastPost" datum isn't the issue. That stuff I can handle. What I can't figure out is how to allow the user to continually refer back to the page that shows him the new posts since his last visit. Since the page is query driven and uses the "LastPost" datum as the filter criteria, I can't update the "LastPost" datum until I know the user is done with his session - - if I do, the query-driven page will show different data.

To put it another way, pseudocode would look something like this...
Code: Select all
If (visit=new) {
   //user is returning - this is a new visit
   get $last_post
   select count(*) from posts where id > $last_post
} elseif (visit=same) {
   //user is hitting this page again, but this is still the same visit
   get $last_post
   select count(*) from posts where id > $last_post
} else {
   //user left, end of visit
   set $last_post = (highest post id that existed while user was here.)
}
But how the heck do you do THAT?!

Last edited by Lchad; May 22nd, 2007 at 11:27. Reason: added code tags for ya!
Reply With Quote

  #2 (permalink)  
Old May 22nd, 2007, 07:16
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: "since your last visit" quandary

If you're using $_SESSION, why not store the "lastpost" data in there when a user starts a new session and refer back to that variable throughout the session, rather than going back to tha database each time?
Reply With Quote
  #3 (permalink)  
Old May 22nd, 2007, 15:05
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: "since your last visit" quandary

I guess I'm a bit skittish wrt session vars. I only recently learned about them/how to use them and began using them, but I ran into so many problems... the sid would change when I posted a form, etc. Maybe I'm doing something wrong, I don't know. (Or maybe it's a Xampp issue and I won't have those problems once the pages are published.)

Your suggestion seems like the logical way to go about it, though. I'll give it a shot and see how it goes.

Thanks, Graham.
Reply With Quote
Reply

Tags
last visit, recent posts

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a "tag" system to find relevant "related" pages MrQuestions PHP Forum 3 Mar 20th, 2008 23:06
[SOLVED] Show "Image" Depends On User "Status"? Monie Classic ASP 6 Oct 16th, 2007 01:22
? IS "meta name="robots" content="?" necessary in pages ? Love2Java Starting Out 6 Aug 8th, 2007 13:48
window.opener.document["nameForm"].getElementById("someid").value; doesnt work drpompeii JavaScript Forum 0 Feb 17th, 2007 23:09
<option value="yes" class="x"> problem in Firefox mameha1977 Web Page Design 1 Jun 21st, 2006 11:20


All times are GMT. The time now is 18:38.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43