473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to force hosting server not cache php codes

khalidbaloch
hello Freind i have almost complted my first php application .. i wrote it in my local webser ..it works fine on my local server acctully the problem interpreting me is in admin page which should redirect the viewer to login page if the session is not set .. i am using this code at the starts of my admin cp page index that controll all the sub pages .
Expand|Select|Wrap|Line Numbers
  1. if (!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
  2. header ("location: login.php");
  3. }
please tell me what to do know ............
Nov 16 '06 #1
11 2044
ronverdonk
4,258 Expert 4TB
So what is the question or the problem?

Ronald :cool:
Nov 16 '06 #2
vssp
268 100+
Hi sorry i am not cleat what u want can u expline briefly ?
Nov 17 '06 #3
sorry dear friend i forget to type the problem acctully i was in little hurry and upset bcz of this problem therefore i am reposting my question


..hello Freinds i have almost complted my first php application .. i wrote it in my local webser ..it works fine on my local server acctully the problem interpreting me is in admin page which should redirect the viewer to login page if the session is not set .. i am using this code at the starts of my admin cp page index that controll all the sub pages .but it is not redirecting to the login.php .instead it taking to admin cp main page ..however there no such problem on my localhost server ..hope you understad what i mean ..
Expand|Select|Wrap|Line Numbers
  1. if (!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
  2. header ("location: login.php");
  3. }
please tell me what to do know ..........
Nov 17 '06 #4
ronverdonk
4,258 Expert 4TB
There is more to this problem then you show us. This code looks fine by itself and can be no reason to re-direct you to a wrong page. So show the relevant other code.

Ronald :cool:
Nov 17 '06 #5
There is more to this problem then you show us. This code looks fine by itself and can be no reason to re-direct you to a wrong page. So show the relevant other code.

Ronald :cool:
hi Ronald : this the complete code of admin cp index page
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  3. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  4. header("Pragma: no-cache");
  5. session_start();
  6. if (!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
  7. header ("location: login.php");
  8. exit;
  9. }
  10. include 'header.php';
  11. require '../dbconnect.php';
  12. $content="pages/$action.php";
  13.         if (strlen($action)==0)
  14.         {
  15.         include("pages/index.php");
  16.         }
  17.         else
  18.         {if (file_exists($content)) {
  19.         include("pages/$action.php");
  20.         }
  21.         else
  22.         {
  23.         echo "page not found";}
  24. }
  25. mysql_close();
  26. include 'footer.php';
  27. ?>
  28. </body>
  29. </html>
i also tried by adding messege under if statment instead .and that was it

if (!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
echo "your not loged in";
exit;

if seesions are not set i see this msg

You are not loged in


it means that if statment is working fine and this is not cache problem .the cach problem has been solved since i added other header function at starts of the page ... the problem is with header redirection ...
Nov 17 '06 #6
ronverdonk
4,258 Expert 4TB
HAve you tried to buffer? As in ob_start() and ob_end_flush? Like this
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. ob_start();
  3. session_start();
  4. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  5. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  6. header("Pragma: no-cache");
  7. if (!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
  8.    header ("location: login.php");
  9. exit;
  10. }
  11.  
  12. include 'header.php';
  13. require '../dbconnect.php';
  14. $content="pages/$action.php";
  15.         if (strlen($action)==0)
  16.         {
  17.         include("pages/index.php");
  18.         }
  19.         else
  20.         {if (file_exists($content)) {
  21.         include("pages/$action.php");
  22.         }
  23.         else
  24.         {
  25.         echo "page not found";}
  26. }
  27. mysql_close();
  28. include 'footer.php';
  29. ob_end_flush();
  30. ?>
  31. </body>
  32. </html>
Ronald :cool:
Nov 17 '06 #7
no i did not tried it yet but now i will . i am unfimailar with these two functions. what do they do ?
Nov 17 '06 #8
no dear friend it is still not working .......
Nov 17 '06 #9
ronverdonk
4,258 Expert 4TB
It is working at my side!!

Ronald :cool:
Nov 17 '06 #10
It is working at my side!!

Ronald :cool:
it is working even in my local webserver but not working on ifastnet.com hosting server and it does not display any php error ... is there any command that force this server to show php errors ..
Nov 17 '06 #11
ronverdonk
4,258 Expert 4TB
You will have to contact the administrator of that server. Not very much you can do when he/she has disabled functions or prevents some processing!

Ronald :cool:
Nov 18 '06 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Martin | last post by:
This is probably more of an HTML question than PHP. Perhaps someone here can answer or point me to a proper newsgroup. How can I force the browser to reload an image from the server? I have a...
1
by: Mr. x | last post by:
Hello, How can I force refreshing of my web site, when a visitor enter my site. Thanks :)
6
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
3
by: Christoph Schittko [MVP] | last post by:
All, I am trying to display a winforms user control inside an HTML page through an <object> tag. Everything works fine and dandy until I sign the assembly that contains the control. Once I start...
2
by: David Krussow | last post by:
The other day in this group someone wrote that one of the ASP.NET hosting providers is "...not an enterprise server, so for example you can't cache web pages..." I'm wondering what "not an...
2
by: Edward Chung | last post by:
I create a user control that is used as a page header for all application's pages. The user control contains a HyperLink control named accountHyperlink whose text can either set to...
0
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I force a reload from the server/prevent caching?...
1
by: William LaMartin | last post by:
I have an aspx page, A.aspx, that uses some xml. The source of the xml is another aspx page, B.aspx. B.aspx is populated with xml by code that depends on several Session variables. This all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.