OZONE Asylum
Forums
DHTML/Javascript
Creating "Buffers" - problems with history and coookies
This page's ID:
28018
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Hello! I am trying to extend my sites session handler to be able to track users between different windows. This will let me do custom message and lastpage handling for each open window instead of each user. I am calling the open windows "Buffers" for the sake of simplicity. I have been working on this for several days, and have been "inches" from a solution several times... Every time, I seem to run into a wall right before success :) I have a server side database table of buffers that are refrenced by sessionid and bufferid. It works perfectly. So far, I have everything working but the javascript that starts a new buffer when the user opens a new window. Sounds easy? I'll list all the attempts I have made and the problems I have run into. Mabye someone will be able to "break though" the wall :) [b]Server Side:[/b] [b]Match http referrer header:[/b] This method works like a chain. I store the contents of the the users current page in the buffer database. On the next page, I look for rows in the database that match the referrer header. New buffers are created when no rows are found to match (the user "branched"). This method worked perfectly untill the user used their back and forward buttons. Consider this: 1) User visits page X, Y, and then Z. 2) User hits "Back" (on page z) 3) Page Y's referrer is page Z, right? Wrong! the referrer is page X, and the chain is broken. :( [b]Client Side:[/b] [b]Split buffer when history.length == 1 (1st try):[/b] In this case, the work of starting a new buffer is done client side when history.length == 1. A new bufferid is created, and assigned to a cookie. The cookie setting function runs in a loop, and sets the buffer coookie every three seconds. The problems with this are obvious. When multiple windows are open, the buffer coookie keeps getting updated with different bufferids from each window. When the user requests a page, the cookie sent along with the request may be from a different window, and the users buffer gets confused. [b]Split buffer when history.length == 1 (2nd try):[/b] Same as the preceeding attempt, but with the addition of a mechanism in place to deactivate the loop when the window is in the background. The problem is that JS (as far as I know) doesn't have a function to return the window's focus state. It has onfucus and onblur event handlers, but how do I tell if the window was loaded in the BG from the start??? Since I don't know the window's intial state, the event handlers seemed to be of little use. [b]Split buffer when history.length == 1 (3rd try):[/b] Same as the 1st attempt, but instead of a loop to set the coookie, the cookie is set on the onunload event (right before a new page is visited). This should work perfectly, but from all my tests it seems that there is some bug in JS which keeps a cookie set from a function attached to the onunload event from being set along with the http headers till two pages later! According to my tests, when you set a cookie from inside a function attached to the onunload event handler, the cookie will not be "visible" to the webserver serving the subsequent page! If anyone knows a way to work around this, please tell me! As you can see, I am almost there. If anyone can find a way to get one of these methods to work, it would be wonderful! -Robur
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »