Lost sessionvariables in firefox - php

I have a pretty strage problem im dealing with.
Lost sessionvariables in firefox.
Im using wordpress and have a subpage that causes the loss.
More specific:
In wordpress there exists a page called My pages (Original page names are in swedish, translated for convinience)
Under this page i have a few subpages. Among these are a page called Create test. There is nothing special about this page, for now only contains the phrase "hello world". If I enter any page other that this, it works.
But this particular page just seems to clear my session variables (wich I use to store login info)
I tried deleting the page in question in the effort to remake it.
While it was deleted I tried navigating around on the page.
Create test was the last item in the subnavigation menu, and now when its gone, the same thing happens on the last menuitem (now Account settings). This leave me to believe its something with the menu.
Even more strange, after recreating Create test, so that this page is now the last item. Still it's Account settings that is the page with the resetting of sessionvars...
I have through echo determined that the session id stays the same, just the variables that get unset.
I have unset($_SESSION['id']); at only one place, and this code is NOT run.
The problem just baffles me and I have no idea why this particular pages does this.

It may be totally unrelated, but we had problem with Firefox and sessions on certain pages in the past. It happened most of the times while developing and therefore refreshing a particular page, have you tried clearing your browser cookies which is where session is stored?
As an addition:
Check that you assign sessions before you write anything to the response stream.
Also we had similar problems with sessions set in a pages that were doing a redirection (i.e. a login page that if successful would set the session and redirect to the another page.)
I'm not sure about PHP but in .NET that can be overcome by explicitly setting not to terminate the response so that all headers are written to the response stream.

Fixed now, actually have no idea what I did. but I've change some html but mostly CSS.
So there is a strong posibility it was CSS-related.

Related

slow iframe loading on website

I have tried to search for this but either I don't know the right search terms or there is no answer.
I have a site that I have made for online ordering. The cart that I made is in its own iframe, mainly as i didn't want the whole page to reload just the cart once something was added or removed etc.
The issue is the cart loads very slowly, at least at first or if pressing refresh. Its almost like it loads after the page is done loading. Is there a way to fix that?
the page for reference is http://www.nomadcss.com.au/posweb
Iframes will load after other page elements because they are often referencing content on a completely different server. However in this case it could be your browser or your internet connection. When I tested the page referenced, everything loaded very quickly. I was able to add and remove things from the cart, opening and closing the iframe, with no lag whatever.

PHP session_cache_limiter not working in Safari?

I've been trying to correctly manage sessions throughout the online ordering system I'm writing using PHP. I've got it functioning the way I intended and I allows users to hit the "back" button mid-process, without screwing up the database.
The only thing I do still want, is to prevent the "back" button being used on (or after) the final "All done" screen.
In step 3 (Confirm and proceed) and step 4 (All done), I've included the lines:
session_cache_limiter('nocache');
session_start();
This works perfectly in IE - you see the page confirming your order, but you get a warning if you try to hit "back". The same applies if you navigate on from the site - you can't see the final step.
The same site doesn't seem to work in Safari (5.1.2). I can hit "back" and see all the content that was displayed (it's getting it from a local cache, and not the server).
The site doesn't accept repeated input, so it's not a massive problem, but it's not the functionality I wanted. Does anyone know how to make this work in Safari?
I don't think the problem is the code, but the browser behaviour.
In Safari, when you press the back button, it just bring you to the same page you were before, just like you opened the new page in another tab and then closed it, even if you set the cache to ‘no-cache’. In Internet Explorer, on the contrary, when you press back, it takes you to the previous page by pointing to its url and loading it again.
Reading here and there, it seems that there's no way to avoid this behaviour, apart from a little trick, which should force the browser to reload the page when you press back: Preventing cache on back-button in Safari 5.

Save URL of AJAX loaded page, so it can be loaded after a refresh

We have an application writted in PHP. Its main view is for example: /pages/index.
Now when the user clicks on certain links, it pulls in other Views via ajax. ie. a call may look like /pages/publish, so the PHP outputs the relevant html for the publish section back to the index view.
The problem we have is we'd like to be able to give the user the option of refreshing and seeing the same view as before. So, my initial thought is this, when we use .load() in jQuery, to take the URL its going to load and store it somewhere to be read by the PHP if the user refreshes. Is the best way to do or can someone think of a better way to do this whole thing?
Check out jQuery.address which should solve your problems! It allows AJAX loading of new pages, and will update the address bar accordingly. If a user saves this URL and reloads it, the script on the page can then load the correct page.
Alternatively, if you're HTML5-only, then you can try history.pushState() which will modify the URL without using the hash symbol, but support isn't 100% yet. (I don't think... it certainly behaves oddly on iPad from my experience.)

How to tell clicking "back" to load the cache?

I realize that you can't 100% know that this will work in all browsers. All I care about is IE 8, Chrome, and Firefox. I need some base headers that I can put at the top of my PHP pages to allow the Forward/Back buttons to load the cache.
Update: on every page I have a logged in user box at the top of the page which gives the user access to their account.
I'm looking for a performance increase in the web site. The user having to reload the site when clicking back/forward creates unnecessary the server load.
Edit: After extensive research into caching and my level of knowledge I do not know a good solution. It also appears that most others don't know either.
What you want is jumping back in the page cache. There are various variables that determine if a page is put into the page cache.
Surfin' Safari has recently written a blog about the page cache. In short a page isn't put into it if:
The page is not completely loaded or uninteresting. (404 errors…)
The page is complicated to halt. This is the case if it has Flash elements or movies.
The page has frames.
The page is secure.
The page has an unload event. In their second blog post they write about alternatives.
Those are the rules Webkit follows, I don't know if it's documented for the other browsers. You can never be sure that a page is put into the page cache. It's best to design websites that don't relay on behavior that can change without notice.
Are you using sessions? If so, before calling session_start() call session_ cache_ limiter('') .
When you call session_start() the cache limiter is reset to the value set in session.cache_limiter (which by default is 'nocache'). If you want your pages to cache you need to explicitly set the cache limiter to something else first.
You can experiment with other values (see http://www.php.net/manual/en/function.session-cache-limiter.php) but I find session_ cache_ limiter('') gives the best result when trying to, for example, prevent forms from being reset when sending a user back after an error.
Although keep in mind this may open privacy concerns if your pages hold personal data, as personalized pages will become cached.

problem with ajax( page refresh)

hi im using ajax to extract all the pages into the main page but am not being able to control the refresh , if somebody refreshes the page returns back to the main page can anybody give me any solutions , i would really appreciate the help...
you could add anchor (#something) to your URL and change it to something you can decode to some particular page state on every ajax event.
then in body.onload check the anchor and decode it to some state.
back button (at least in firefox) will be working alright too. if you want back button to work in ie6, you should add some iframe magic.
check various javascript libraries designed to support back button or history in ajax environment - this is probably what you really need. for example, jQuery history plugin
You can rewrite the current url so it gives pointers to where the user was - see Facebook for examples of this.
I always store the 'current' state in PHP session.
So, user can refresh at any time and page will still be the same.
if somebody refreshes the page returns back to the main page can anybody give me any solutions
This is a feature, not a bug in the browser. You need to change the URL for different pages. Nothing is worse then websites that use any kind of magic either on the client side or the server side which causes a bunch of completely different pages to use the same URL. Why? How the heck am I gonna link to a specific page? What if I like something and want to copy & paste the URL into an IM window?
In other words, consider the use cases. What constitutes a "page"? For example, if you have a website for stock quotes--should each stock have a unique URL? Yes. Should you have a unique URL for every variation you can make to the graph (i.e. logarithmic vs linear, etc)? Depends--if you dont, at least provide a "share this" like google maps does so you can have some kind of URL that you can share.
That all said, I agree with the suggestion to mess with the #anchor and parse it out. Probably the most elegant solution.

Categories