Page 1 of 1
problems with cookies
Posted: Tue Oct 04, 2005 9:20 am
by sebs
I need to transfer one cookie to a third page.As I understood the cookie needs to be set before any output.The problem is that I need to transmit through that cookie on what it has been clicked.Can you help me?Is there a way to know from which page you have been redirected to the curent one?
Re: problems with cookies
Posted: Tue Oct 04, 2005 9:57 am
by chrys
sebs wrote:I need to transfer one cookie to a third page.As I understood the cookie needs to be set before any output.The problem is that I need to transmit through that cookie on what it has been clicked.Can you help me?Is there a way to know from which page you have been redirected to the curent one?
You should look into sessions.
http://www.php.net/session_start
It basically goes like this:
put session_start(); at the very top of every page in your site.
To register a variable, set it like this:
$_SESSION['var'] = "john";
Then on your next page:
echo $_SESSION['var'];
Output will be:
john
Just make sure to have session_start at the top of the page before any output.
Posted: Tue Oct 04, 2005 10:05 am
by sebs
ok,but if I do that it gives me a php error in windows and still not working.I'm using phptriad with a new php,I think 5.And I can't put on the very top of every page because I have some static pages between them
Posted: Tue Oct 04, 2005 10:24 am
by chrys
sebs wrote:ok,but if I do that it gives me a php error in windows and still not working.I'm using phptriad with a new php,I think 5.And I can't put on the very top of every page because I have some static pages between them
Could you paste the error?
Are you running this off of IIS or Apache in Windows?
Posted: Tue Oct 04, 2005 10:47 am
by sebs
I am running apache.the error that gives windows XP(all errors of windows are given the same)only that it sais php.exe created the error.
Posted: Tue Oct 04, 2005 10:58 am
by sebs
is there any variable in which is kept the files name (the file is static) that redirected me to the current page?
Posted: Tue Oct 04, 2005 10:58 am
by chrys
sebs wrote:I am running apache.the error that gives windows XP(all errors of windows are given the same)only that it sais php.exe created the error.
Ah it's an executable error... that's really weird, and it shouldn't be doing that because of PHP code. I have no experience with windows apache, so I Can't help there. But let's take a look at the code. Can you paste the code for the file that is crashing?
Posted: Wed Oct 05, 2005 2:11 am
by sebs
<?php
session_start();
echo $_SESSION['search'];
?>
This is in the third page!
And in the first page I have:
<?php
session_start();
$_SESSION['search'] = "1234";
...//sql query that is working ok;
?>
session_start() it's put on every file at the start of file write?
Sorry I answered so late
Posted: Wed Oct 05, 2005 5:08 am
by Jenk
Please use
Code: Select all
tags for other code or output
If you are receiving executable errors with php.exe, you have either a corrupt Apache installation, corrupt PHP installation, corrupt Windows installation or any combination of the above.
Fix those, else you will forever receive errors that you will think is your code