Is it possible to add session_start (); at the top of my entire site?
I am using the following code in a section of our buying process on our website, placing it at the top of each step that uses sessions.
<?php
session_cache_limiter('private_no_expire'); // must go before session start
session_start();
I want to start using sessions more widely on a website, for example in the login area.
I have a file called "all.php" which includes all my classes / objects and is shared at the start of every page on my system. I thought that removing the above code from all the individual ecommerce files and adding "all.php" to the beginning would be a good idea since it was system-wide and the first thing that loads on the page.
As this is happening, my google login area ran into problems. It keeps throwing users to the login page after they have moved several links. It seems that when you click on a URL that was already on it, it doesn't like it and it just takes you back to the start. If you add & 1 = 1 to the url you have been to before, it tricks the system into allowing you to visit the page because it is a new unique url. So the cache is definitely confusing.
I don't use sessions at all in this section of the website, so you don't like the fact that you actually log out ... it just sends you to the page where you started.
Can anyone shed some light on what might be wrong here?
Could it be using session_cache_limiter ('private_no_expire');
I am using the above line because my checkout process uses POST forms and clicking on the back button gives ugly resubmit messages.
http://php.net/manual/en/function.session-cache-limiter.php
UPDATE:
Commenting that the first line helped and the problem stopped:
//session_cache_limiter('private_no_expire'); // must go before session start
This is a temporary fix as it means the Back button triggers retransmission warnings. It just means that I need to implement it correctly, but I still wanted to understand why this line does it:
source to share
It looks like we are creating a PHP login panel. Once the user is logged in, you need to start the session using session_start (), and when the user is logged out, stop the session using ssession_unset (). This will solve your problems. Give it a try and let me know if it works.
Keep coding.
source to share
The quickest and cleanest way to get around this is when you do the processing of the form data, instead of displaying the information on the page that is doing the processing.
Header('Location: http://www.domain.com/page.php');
If, for example, you add an item to your shopping cart, redirect the user to either your card page or to this page.
Since doing this, my customer login area has encountered problems. It keeps throwing users back to the login page after they've navigated a few links. It seems when you hit a URL that you've already been on it doesn't like it and just sends you back to the start. If you add &1=1 onto a url that you've been onto before, it tricks the system into letting you visit the page because its a new unique url. So the cache is definitely messing up.
session_cache_limiter('private_no_expire')
... You don't need this for what you are doing.
source to share