Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
On 20/08/07, tedd [EMAIL PROTECTED] wrote: At 10:40 PM +0200 8/19/07, Wouter van Vliet / Interpotential wrote: What you're proposing, is to actually display some content on another page then were the content is originally intended? I'm sorry, but I would consider that 'bad practice'. To me, it makes perfect sense that you don't want to leave the user on the page where login was originally handled. For various reasons. One very obvious would be the 'refresh thing', where your browser asks the user if they want to send the form again. Quite annoying. Then, what about bookmarks? ... No, what I had proposed was an alternate method to accomplish what you said you wanted. But, it appears that my efforts and the demo did not receive sufficient attention for you to understand what wass being presented. Instead, you tell me that what I've shown you is bad practice -- interesting. First of all - I didn't ask the initial question ;-). Other than that, I think our philosophies our basically the same. But when you say that you are redirecting the user to another page, while you are actually including a php script - that's not my understanding of redirecting. You said that you wanted to remove login from the browser history, which is screwing around with the user's browser and is clearly bad practice. Generally yes, removing a page from the browser's history would be considered bad practice. However, we are not really talking about a page here. What I understood from the initial question is as follows: - http://www.site.com/ contains some login form, action of that form is (for example) /login.php - The user is sent to /login.php where the login is checked - From there, the user either gets to a content page where it would typically show welcome {user} or something, or back to the index page when login failed - As you see, login.php is not really a page but more of a 'pseudo page' and therefore I cannot see any reason not to send a proper 303 header. see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html My method simply stops the user from visiting the same page more than once during a session and leaves their browser data alone -- nothing bad practice about that! AFTER my demo runs, if you repeatedly refresh the page you are directed to, then certainly that would become annoying. But that wasn't the intent, nor part of the demo, which you clearly didn't read and obviously didn't understand. As far as bookmarking the page, but of course you can bookmark the page! Did you even try? Oh well, so much for trying to help someone understand sessions. As my mother often said No good deed ever goes unpunished. I've got another one, There is no selfless good deed. If you had simply said, I don't understand, please explain; or asked a question or two; or said thanks, but no thanks, I'm going to do it another way, then that would have been fine. But to say that the demo I prepared for you exhibited bad practice, especially when you are absolutely friggen clueless as to what it is doing, is a bit too much -- I'll be sure to pass over your post in the future. I don't think there wasn't anybody who didn't appriciate your suggestion. Only thing I was trying to do was chip in my two cents. Again, I wasn't the one who originally asked the question and I certainly am not friggen clueless. I just came to think about what the teacher at my Flex course from a couple of months ago said about good and bad practice. He said there is none. If your solution works good for you, that's your good practice. And if mine doesn't work for you, it's your bad practice - while it is still my good practice. Something however I am trying to fight against, if you let me put it like that - is people approaching scripts as if they are pages. When you are including a script that is usually called as a page into another script you should be very aware for any clashes between variables. Another reason why it may be easier to just put in a Location: header and call your script as it was originally intended. Wouter tedd --- I would definately go for the Location: header solution! On 19/08/07, tedd [EMAIL PROTECTED] wrote: At 8:52 AM +0200 8/19/07, Otto Wyss wrote: In my case I could easilly do without redirection but just exit and fall back on the calling page. Yet I want to remove the login page from the browser history. Does the header function have the same effect? O. Wyss: Instead of messing with the user's browser (not good IMO), why not use $_SESSION and make it such that if the user selects the log-on page again, they are redirected to another page? You don't even need header() to do that. Here's an example: http://webbytedd.com/bb/one-time You will only see that page only once -- unless you find a way to clear the session. The process is simply to set a session variable and allow the user to see the page once. Upon
Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
At 12:42 PM +0200 8/20/07, Wouter van Vliet / Interpotential wrote: Only thing I was trying to do was chip in my two cents. Again, I wasn't the one who originally asked the question and I certainly am not friggen clueless. Maybe not, but you made some pretty clueless remarks -- like if you could book-mark the page, the annoying refresh remark, and saying the demo displayed bad practice. None were germane to the intent of the demo, let alone valid. I just came to think about what the teacher at my Flex course from a couple of months ago said about good and bad practice. He said there is none. If your solution works good for you, that's your good practice. And if mine doesn't work for you, it's your bad practice - while it is still my good practice. That's just an excuse to do what you want and call it good -- but, there are good and bad practices. Something however I am trying to fight against, if you let me put it like that - is people approaching scripts as if they are pages. When you are including a script that is usually called as a page into another script you should be very aware for any clashes between variables. Another reason why it may be easier to just put in a Location: header and call your script as it was originally intended. Now, I'm clueless as to what you're talking about. I think most people agree as to what a web page is and if we are using web languages to communicate with the user, then that is our medium. There are many ways to use web pages and Location: is only one of them. Limit yourself as you see fit. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies and sent headers
M. Sokolewicz wrote: On a sidenote, 99% of the world never calls ob_flush (or any such function) since PHP flushes the buffer automatically at the end of its execution. I'll keep the ob_end_flush just for showing what's going on, but thanks for the hint. The reason why setting cookies for you doesn't work is because of the way a HTTP response is structured. It consists of 2 parts: header and body separated by 2 new lines (\n\n). It is _required_ that _all_ headers come _before_ the body. Cookies are actually headers (a set-cookie: [...] header) aswell as any headers set via php's header() function. Any output made by the script (be it a single whitespace, a bunch of text, etc.) will automatically flush the headers, followed by the separator (\n\n) followed by the specified output. After that has been sent, everything outputted will be dumped into the body of the response (simply because you can't go back to the headers which were already sent earlier), so you can't set cookies (which are headers themselves). Thanks, now it's understandable. So, why does output buffering help here? Simply put, instead of dumping headers and any other output directly to the client, PHP buffers it all into memory. As such, since it hasn't been sent yet, PHP can still alter/add headers even though it also has body-output. Once it receives the command, PHP will send all headers, the separator and the output to the client. This is done when PHP encounters an ob_flush or ob_end_flush call, _and_ when the script has finished execution automatically. The documentation seems pretty clear to me, however, if you feel it should be clarified better, feel free to send a patch to the [EMAIL PROTECTED] list. - Tul O. Wyss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
M. Sokolewicz wrote: emits). Now, I'm not going to go into how redirecting that way won't work (or at least shouldn't), but a hint would be to do it properly using header('Location: [...]') instead. I'm aware that using Javascript within a PHP code block doesn't seems logical yet I haven't known header ('Location...). In my case I could easilly do without redirection but just exit and fall back on the calling page. Yet I want to remove the login page from the browser history. Does the header function have the same effect? O. Wyss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies and sent headers
On Sat, 18 Aug 2007 17:03:35 +0200, M. Sokolewicz wrote: The reason why setting cookies for you doesn't work is because of the way a HTTP response is structured. It consists of 2 parts: header and body separated by 2 new lines (\n\n). It is _required_ that _all_ headers come _before_ the body. Cookies are actually headers (a Actually, it is perfectly possible (in theory) to send most headers _after_ the body. See RFC 2616, sections 14.40, 3.6.1 and 14.39. I don't think it is possible with (non-nph) PHP though. /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
At 8:52 AM +0200 8/19/07, Otto Wyss wrote: In my case I could easilly do without redirection but just exit and fall back on the calling page. Yet I want to remove the login page from the browser history. Does the header function have the same effect? O. Wyss: Instead of messing with the user's browser (not good IMO), why not use $_SESSION and make it such that if the user selects the log-on page again, they are redirected to another page? You don't even need header() to do that. Here's an example: http://webbytedd.com/bb/one-time You will only see that page only once -- unless you find a way to clear the session. The process is simply to set a session variable and allow the user to see the page once. Upon returning, the session variable is checked and if it is not null, then the user is redirected to another page like so: if($visit != null) { ob_clean(); include('a.php'); exit(0); } Very simple. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
What you're proposing, is to actually display some content on another page then were the content is originally intended? I'm sorry, but I would consider that 'bad practice'. To me, it makes perfect sense that you don't want to leave the user on the page where login was originally handled. For various reasons. One very obvious would be the 'refresh thing', where your browser asks the user if they want to send the form again. Quite annoying. Then, what about bookmarks? ... I would definately go for the Location: header solution! On 19/08/07, tedd [EMAIL PROTECTED] wrote: At 8:52 AM +0200 8/19/07, Otto Wyss wrote: In my case I could easilly do without redirection but just exit and fall back on the calling page. Yet I want to remove the login page from the browser history. Does the header function have the same effect? O. Wyss: Instead of messing with the user's browser (not good IMO), why not use $_SESSION and make it such that if the user selects the log-on page again, they are redirected to another page? You don't even need header() to do that. Here's an example: http://webbytedd.com/bb/one-time You will only see that page only once -- unless you find a way to clear the session. The process is simply to set a session variable and allow the user to see the page once. Upon returning, the session variable is checked and if it is not null, then the user is redirected to another page like so: if($visit != null) { ob_clean(); include('a.php'); exit(0); } Very simple. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
Re: [PHP] Redirection with header (was Re: [PHP] Cookies and sent headers)
At 10:40 PM +0200 8/19/07, Wouter van Vliet / Interpotential wrote: What you're proposing, is to actually display some content on another page then were the content is originally intended? I'm sorry, but I would consider that 'bad practice'. To me, it makes perfect sense that you don't want to leave the user on the page where login was originally handled. For various reasons. One very obvious would be the 'refresh thing', where your browser asks the user if they want to send the form again. Quite annoying. Then, what about bookmarks? ... No, what I had proposed was an alternate method to accomplish what you said you wanted. But, it appears that my efforts and the demo did not receive sufficient attention for you to understand what wass being presented. Instead, you tell me that what I've shown you is bad practice -- interesting. You said that you wanted to remove login from the browser history, which is screwing around with the user's browser and is clearly bad practice. My method simply stops the user from visiting the same page more than once during a session and leaves their browser data alone -- nothing bad practice about that! AFTER my demo runs, if you repeatedly refresh the page you are directed to, then certainly that would become annoying. But that wasn't the intent, nor part of the demo, which you clearly didn't read and obviously didn't understand. As far as bookmarking the page, but of course you can bookmark the page! Did you even try? Oh well, so much for trying to help someone understand sessions. As my mother often said No good deed ever goes unpunished. If you had simply said, I don't understand, please explain; or asked a question or two; or said thanks, but no thanks, I'm going to do it another way, then that would have been fine. But to say that the demo I prepared for you exhibited bad practice, especially when you are absolutely friggen clueless as to what it is doing, is a bit too much -- I'll be sure to pass over your post in the future. tedd --- I would definately go for the Location: header solution! On 19/08/07, tedd [EMAIL PROTECTED] wrote: At 8:52 AM +0200 8/19/07, Otto Wyss wrote: In my case I could easilly do without redirection but just exit and fall back on the calling page. Yet I want to remove the login page from the browser history. Does the header function have the same effect? O. Wyss: Instead of messing with the user's browser (not good IMO), why not use $_SESSION and make it such that if the user selects the log-on page again, they are redirected to another page? You don't even need header() to do that. Here's an example: http://webbytedd.com/bb/one-time You will only see that page only once -- unless you find a way to clear the session. The process is simply to set a session variable and allow the user to see the page once. Upon returning, the session variable is checked and if it is not null, then the user is redirected to another page like so: if($visit != null) { ob_clean(); include('a.php'); exit(0); } Very simple. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471 -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cookies and sent headers
If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies and sent headers
Kelvin Park wrote: Otto Wyss wrote: If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss ob_start() might help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies and sent headers
You best option would be to go through all of your include'd or require'd files and make sure there is no whitespace before and after you open your php tags. Those are often the cause for such problems. The easy way would indeed be to use output buffering. In that case, put the call to ob_start(); on the first line of the file you're calling. You will still have to make sure to not have any whitespace before your ?php opening. To even bypass that, the output_buffering ini setting might be useful. Alter it in your php.ini if you can, otherwise try your apache vhost configuration or .htaccess. The syntax there is: php_flag output_buffering On Good luck! On 18/08/07, Kelvin Park [EMAIL PROTECTED] wrote: Kelvin Park wrote: Otto Wyss wrote: If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss ob_start() might help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Interpotential.com Phone: +31615397471
RE: [PHP] Cookies and sent headers
sessions and cookies either need to be set at the beginning of the page, or you can look into the ob_start(), ob_flush() functions to use output buffering bastien To: php-general@lists.php.net Date: Sat, 18 Aug 2007 11:25:54 +0200 From: [EMAIL PROTECTED] Subject: [PHP] Cookies and sent headers If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo ; exit; } O. Wyss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+worldmkt=en-USform=QBRE -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies and sent headers
ob_start() at the beginning and ob_end_flush() at the end of the PHP section seems to do the trick albeit I've still problems to understand why. The description in the manual is rather sparse unfortunately. Is there any more information about what's going on? O. Wyss Wouter van Vliet / Interpotential wrote: You best option would be to go through all of your include'd or require'd files and make sure there is no whitespace before and after you open your php tags. Those are often the cause for such problems. The easy way would indeed be to use output buffering. In that case, put the call to ob_start(); on the first line of the file you're calling. You will still have to make sure to not have any whitespace before your ?php opening. To even bypass that, the output_buffering ini setting might be useful. Alter it in your php.ini if you can, otherwise try your apache vhost configuration or .htaccess. The syntax there is: php_flag output_buffering On Good luck! On 18/08/07, Kelvin Park [EMAIL PROTECTED] wrote: Kelvin Park wrote: Otto Wyss wrote: If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss ob_start() might help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Cookies and sent headers
The commands start and use an output buffer, a chunk of memory that stores all the output on the server until the ob_flush, the buffer flush, function is called. You need to be aware that in high load situations this may adversly affect performance since it loads the servers memory, also be aware that you may hit a memory limit for large pages. This is server / OS depandant so you may want to read up on server documentation bastien To: php-general@lists.php.net; [EMAIL PROTECTED] Date: Sat, 18 Aug 2007 16:39:29 +0200 From: [EMAIL PROTECTED] CC: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] Cookies and sent headers ob_start() at the beginning and ob_end_flush() at the end of the PHP section seems to do the trick albeit I've still problems to understand why. The description in the manual is rather sparse unfortunately. Is there any more information about what's going on? O. Wyss Wouter van Vliet / Interpotential wrote: You best option would be to go through all of your include'd or require'd files and make sure there is no whitespace before and after you open your php tags. Those are often the cause for such problems. The easy way would indeed be to use output buffering. In that case, put the call to ob_start(); on the first line of the file you're calling. You will still have to make sure to not have any whitespace before your To even bypass that, the output_buffering ini setting might be useful. Alter it in your php.ini if you can, otherwise try your apache vhost configuration or .htaccess. The syntax there is: php_flag output_buffering On Good luck! On 18/08/07, Kelvin Park wrote: Kelvin Park wrote: Otto Wyss wrote: If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo ; exit; } O. Wyss ob_start() might help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies and sent headers
On a sidenote, 99% of the world never calls ob_flush (or any such function) since PHP flushes the buffer automatically at the end of its execution. The reason why setting cookies for you doesn't work is because of the way a HTTP response is structured. It consists of 2 parts: header and body separated by 2 new lines (\n\n). It is _required_ that _all_ headers come _before_ the body. Cookies are actually headers (a set-cookie: [...] header) aswell as any headers set via php's header() function. Any output made by the script (be it a single whitespace, a bunch of text, etc.) will automatically flush the headers, followed by the separator (\n\n) followed by the specified output. After that has been sent, everything outputted will be dumped into the body of the response (simply because you can't go back to the headers which were already sent earlier), so you can't set cookies (which are headers themselves). So, why does output buffering help here? Simply put, instead of dumping headers and any other output directly to the client, PHP buffers it all into memory. As such, since it hasn't been sent yet, PHP can still alter/add headers even though it also has body-output. Once it receives the command, PHP will send all headers, the separator and the output to the client. This is done when PHP encounters an ob_flush or ob_end_flush call, _and_ when the script has finished execution automatically. The documentation seems pretty clear to me, however, if you feel it should be clarified better, feel free to send a patch to the [EMAIL PROTECTED] list. - Tul Bastien Koert wrote: The commands start and use an output buffer, a chunk of memory that stores all the output on the server until the ob_flush, the buffer flush, function is called. You need to be aware that in high load situations this may adversly affect performance since it loads the servers memory, also be aware that you may hit a memory limit for large pages. This is server / OS depandant so you may want to read up on server documentation bastien To: php-general@lists.php.net; [EMAIL PROTECTED] Date: Sat, 18 Aug 2007 16:39:29 +0200 From: [EMAIL PROTECTED] CC: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] Cookies and sent headers ob_start() at the beginning and ob_end_flush() at the end of the PHP section seems to do the trick albeit I've still problems to understand why. The description in the manual is rather sparse unfortunately. Is there any more information about what's going on? O. Wyss Wouter van Vliet / Interpotential wrote: You best option would be to go through all of your include'd or require'd files and make sure there is no whitespace before and after you open your php tags. Those are often the cause for such problems. The easy way would indeed be to use output buffering. In that case, put the call to ob_start(); on the first line of the file you're calling. You will still have to make sure to not have any whitespace before your To even bypass that, the output_buffering ini setting might be useful. Alter it in your php.ini if you can, otherwise try your apache vhost configuration or .htaccess. The syntax there is: php_flag output_buffering On Good luck! On 18/08/07, Kelvin Park wrote: Kelvin Park wrote: Otto Wyss wrote: If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo ; exit; } O. Wyss ob_start() might help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Cookies and sent headers
Hi, Its not the problem of cookies. Its problem of redirection or the parent.location.replace function. I mean if you already output something on the page and tries to redirect then this problem happens. Redirect before outputting anything on the page.. like space is also an output. Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Otto Wyss [mailto:[EMAIL PROTECTED] Sent: Saturday, August 18, 2007 2:56 PM To: php-general@lists.php.net Subject: [PHP] Cookies and sent headers If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookies and sent headers
bullshit, what he sees is a warning emitted by PHP, his redirect is done using JavaScript (which is clientside and has no, 0.0 effect on what PHP emits). Now, I'm not going to go into how redirecting that way won't work (or at least shouldn't), but a hint would be to do it properly using header('Location: [...]') instead. - Tul Sanjeev N wrote: Hi, Its not the problem of cookies. Its problem of redirection or the parent.location.replace function. I mean if you already output something on the page and tries to redirect then this problem happens. Redirect before outputting anything on the page.. like space is also an output. Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Otto Wyss [mailto:[EMAIL PROTECTED] Sent: Saturday, August 18, 2007 2:56 PM To: php-general@lists.php.net Subject: [PHP] Cookies and sent headers If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie (l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] Cookies and sent headers
-- Forwarded message -- From: Kelvin Park [EMAIL PROTECTED] Date: Aug 18, 2007 4:34 PM Subject: Re: [PHP] Cookies and sent headers To: M. Sokolewicz [EMAIL PROTECTED] the javascript code can definitely change to head(location: whatever.php) for redirection, if that's the solution, that would be the way to go, but if you're encountering quite similar problems later you can try ob_start() or whatever that was recommended in the comments before M. Sokolewicz's bullshitting comment. On 8/18/07, M. Sokolewicz [EMAIL PROTECTED] wrote: bullshit, what he sees is a warning emitted by PHP, his redirect is done using JavaScript (which is clientside and has no, 0.0 effect on what PHP emits). Now, I'm not going to go into how redirecting that way won't work (or at least shouldn't), but a hint would be to do it properly using header('Location: [...]') instead. - Tul Sanjeev N wrote: Hi, Its not the problem of cookies. Its problem of redirection or the parent.location.replace function. I mean if you already output something on the page and tries to redirect then this problem happens. Redirect before outputting anything on the page.. like space is also an output. Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Otto Wyss [mailto:[EMAIL PROTECTED] Sent: Saturday, August 18, 2007 2:56 PM To: php-general@lists.php.net Subject: [PHP] Cookies and sent headers If built a simple login page and store any information within $_SESSION's. Yet I'd like to move these into cookies but I always get an error about sent headers. Is there a way to circumvent this problem without changing too much in the page? The setting of the cookies happens just at the end of the page. if (!$errortext and $Anmelden) { if (!empty($Permanent)) { $expires = time()+ 365 * 86400; // 365 days setcookie (l.Lastname, $_SESSION['l_Lastname'], $expires); setcookie ( l.Firstname, $_SESSION['l_Firstname'], $expires); setcookie (l.Email1, $_SESSION['l_Email1'], $expires); setcookie (l.Email2, $_SESSION['l_Email2'], $expires); } echo script type=\text/javascript\ parent.location.replace('$index_php; /script; exit; } O. Wyss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php