Jump to content

Alternative to cookies? Reliability of HTTP_REFERER?


iwannabeleet

Recommended Posts

Okay I really need help with this one, I have a unique problem and cannot figure out the best solution. Lemme try and make this as brief as possible, and thank you VERY much in advance for those who actually read through this:

 

THE SCENARIO:

I have a website whose index page presents a quick Flash intro, then redirects to the main website. The website owner wants a javascript lytebox-style popup to display a particular photo once when the page is first visited, but only once.

 

THE PROBLEM:

When the user visits the main website page, the Javascript popup is triggered onLoad, but because the links on the page force a reload anytime they navigate around, the popup is displaying every time (ie index2.php?page=main, index2.php?page=contact, index2.php?=otherstuff). It is too late to change the basic structure of the site itself (hindsight is 20/20  :-[)

 

THE SECOND PROBLEM:

At first I tried having my flash intro redirect to something like 'index2.php?popup=1'. I thought I was being clever because then the only time the popup would show is if the URL had that popup variable set in $_GET. So once they navigate elsewhere, that $popup variable disappears. Unfortunately, if they navigate to a new page, and then click 'BACK' in their browser, it will send them back to the original URL with $popup still in there, so they see the popup a second time. I cannot figure out how to avoid that or how to remove $popup from the GET so when they click Back it doesn't show again. Seems like POST would have the same issue.

 

POSSIBLE SOLUTIONS:

 

1) Cookies. Install a small session PHP cookie to check if the popup has displayed, if not, show it, if it has, do nothing. (I'm trying  to avoid this).

2) Some kind of global-variable voodoo. I don't know if this is possible, but is there some kind of magic global variable that will retain its value site-wide between interpreter fire-ups? I guess not because that would eliminate the need for cookies in the first place?

3) Check the HTTP_REFERER. Ie, did we arrive at this page from the initial flash intro? If so, show the popup, if not, do nothing. Downside here: reliability -- will this even work consistently enough to be a viable solution?

4) ...?

 

 

Okay so I know that was long winded but i wanted to try and sum up everything I've thought of. Am I missing something terribly obvious here? Does anyone have any suggestions/solutions/advice?

 

Thank you all very much~

Link to comment
Share on other sites

not really a good solution but check the logs, only works per session though since it's the first page, if it wasn't you could do on user. But shouldn't a session var work? If already set then don't do...

 

*smacks forehead*

 

Yes I guess that is the 'global variable voodoo' I was talking about. Sorry, I am a noob. Thank you both for pointing me in the right direction. I think that will solve the problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.