Jump to content

Archived

This topic is now archived and is closed to further replies.

Apyvala

Page loads only after refresh

Recommended Posts

Hi,

i have a website on three speeches - Lithuania ( lt ), English ( en ) and Russian ( ru ). Website on one server works perfect, but on another server not.

In index file i have such code:

if (!session_is_registered("speech")) {
if ($_SESSION['speech'] == "") {
session_register("speech");
$_SESSION['speech'] = "lt";
}

that is, default speech is lt. Moreower i have three links:

<a href="change_speech.php?speech=lt" class="speech">LT</a> <a href="change_speech.php?speech=en" class="speech">EN</a> <a href="change_speech.php?speech=ru" class="speech">RU</a>

My change_speech.php file looks:

<?php
session_start();

$_SESSION['speech'] = $_GET['speech'];

header ("Location: index.php");
?>


The problem: when i push on links "LT", "EN" or "RU" i see white page, i need to push F5 ( to refresh page ) than i could see the page.
This problem occurs only on one server, on another server i haven't such problem.

Any ideas?

Share this post


Link to post
Share on other sites
maybe it has something to do with the way your php.ini file is configured but I don't know how to help with that.

Share this post


Link to post
Share on other sites
[!--quoteo(post=367461:date=Apr 22 2006, 10:13 AM:name=Apyvala)--][div class=\'quotetop\']QUOTE(Apyvala @ Apr 22 2006, 10:13 AM) [snapback]367461[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi,

i have a website on three speeches - Lithuania ( lt ), English ( en ) and Russian ( ru ). Website on one server works perfect, but on another server not.

In index file i have such code:

if (!session_is_registered("speech")) {
if ($_SESSION['speech'] == "") {
session_register("speech");
$_SESSION['speech'] = "lt";
}

that is, default speech is lt. Moreower i have three links:

<a href="change_speech.php?speech=lt" class="speech">LT</a> <a href="change_speech.php?speech=en" class="speech">EN</a> <a href="change_speech.php?speech=ru" class="speech">RU</a>

My change_speech.php file looks:

<?php
session_start();

$_SESSION['speech'] = $_GET['speech'];

header ("Location: index.php");
?>
The problem: when i push on links "LT", "EN" or "RU" i see white page, i need to push F5 ( to refresh page ) than i could see the page.
This problem occurs only on one server, on another server i haven't such problem.

Any ideas?
[/quote]


try exit(); after the header call in change_speech.php. I have found that you have to force some browsers to do that header function.

Share this post


Link to post
Share on other sites
Thank you for suggestions. But my website doesn't work well after the you suggested changes.

I has perceived an interesting thing. I am using:

HTML code:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


then i change it to:

<meta http-equiv="Content-Type" content="text/html; charset=win-1257" />


Than the website works well. Hmmm... it is very interesting for me.

win-1257 - Lithuanian encoding

Share this post


Link to post
Share on other sites
When using sessions, make sure you have [code]<?php session_start(); ?>[/code] at the start of each script where sessions are being used. Do not use the functions session_is_registered() and session_register(). Instead use [code]<?php if (!isset($_SESSION['var])) ?>[/code] for [code]<?php if (!session_is_registered('var') ?>[/code]

So your index.php code should look something like:
[code]<?php
session_start();
if (!isset($_SESSION['speech']) || (isset($_SESSION['speech']) && $_SESSION['speech'] == '')))
     $_SESSION['speech'] = 'lt';
?>[/code]

In your change_speech.php code, you should do something like:
[code]<?php
session_start();
$_SESSION['speech'] = (isset($_GET['speech']))?$_GET['speech']:'lt';
?>[/code]

Ken

Share this post


Link to post
Share on other sites
Thank you very much for much for help.
My page works perfect when i replace:

session_start();

to

if (!isset($_SESSION)) {
session_start();
}

Share this post


Link to post
Share on other sites

×

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.