PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 1:52 pm
Yes I posted this at the end of my last post but I think this deserves its own thread since its entirly different subject. I have this quick code snip:
Code: Select all
<?php
if (!empty($_GET['lang']))
{
$langs = array('eng', 'est', 'fin', 'rus');
$language = strtolower($_GET['lang']);
$language = trim($language);
if (in_array($language, $langs))
{
$_SESSION['lang'] = $language;
header("Location: ".$_SESSION['last_page']);
die();
}
}
if (!empty($_SERVER['HTTP_REFERER']))
$_SESSION['last_page'] = $_SERVER['HTTP_REFERER'];
else
$_SESSION['last_page'] = $GLOBALS['sroot'];
?>
now when I header it the new value for $_SESSION['lang'] does not stay but if i don't header to the new location then it works fine (but i need the header!). Any ideas?
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 2:01 pm
Code: Select all
if (!empty($_GET['lang']))
{
$langs = array('eng', 'est', 'fin', 'rus');
$language = strtolower($_GET['lang']);
$language = trim($language);
if (in_array($language, $langs))
{
$_SESSION['lang'] = $language;
session_write_close();
header("Location: ".$_SESSION['last_page']);
die();
}
}
does not work
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Mon Apr 17, 2006 2:03 pm
Code: Select all
$last_page = $_SESSION['last_page'];
session_write_close();
header("Location: ".$last_page);
shot in the dark, I havn't had experience with this function really..
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 2:08 pm
no luck. anyone else? version info:
PHP Version 5.0.5-2ubuntu1.2
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Apr 17, 2006 2:12 pm
Start the session prior to this redirection page being hit.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 2:16 pm
feyd wrote: Start the session prior to this redirection page being hit.
say again? the session has already been started. this is confirmed when I put another session start above the setting of the new session[lang] as it gives me the error stuff. or did you mean somthing else?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Apr 17, 2006 2:50 pm
I mean start the session on a previous page. There's no need to write out session headers (overall) after they have already been started previously.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 2:54 pm
...i am? are you telling me to do somthing different? sessions have been started ahhhh!
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Mon Apr 17, 2006 3:45 pm
Two questions:
1. Did you use session_start() at all?
2 Which firewall do you have?
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 4:26 pm
yes, the session has already been started. this page is included in my header file that has my session start.
no, i don't have a firewall setup at all. no firewall.
printf
Forum Contributor
Posts: 173 Joined: Wed Jan 12, 2005 5:24 pm
Post
by printf » Mon Apr 17, 2006 4:32 pm
Can we see more of the script! Where is this being set, $_SESSION['last_page']. Also you say it not working, what exactly is happening?
printf!
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 4:43 pm
wait. never mind. forget i exist. please delete this thread.
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Mon Apr 17, 2006 4:57 pm
shiznatix wrote: no, i don't have a firewall setup at all. no firewall.
You really don't have a firewall?!
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Mon Apr 17, 2006 4:58 pm
Oren wrote: shiznatix wrote: no, i don't have a firewall setup at all. no firewall.
You really don't have a firewall?!
i like to live life on the edge.