Apyvala Posted April 22, 2006 Share Posted April 22, 2006 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: <?phpsession_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 Link to comment Share on other sites More sharing options...
Ninjakreborn Posted April 23, 2006 Share Posted April 23, 2006 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. Quote Link to comment Share on other sites More sharing options...
mb81 Posted April 23, 2006 Share Posted April 23, 2006 [!--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: <?phpsession_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. Quote Link to comment Share on other sites More sharing options...
Apyvala Posted April 23, 2006 Author Share Posted April 23, 2006 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 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 23, 2006 Share Posted April 23, 2006 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]<?phpsession_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]<?phpsession_start();$_SESSION['speech'] = (isset($_GET['speech']))?$_GET['speech']:'lt';?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Apyvala Posted April 24, 2006 Author Share Posted April 24, 2006 Thank you very much for much for help.My page works perfect when i replace:session_start(); toif (!isset($_SESSION)) { session_start(); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.