php - It wont set the session? -
I have this PHP login system, I was working on it on a local host, I bought a webhost hotel and now this work Now does not, and I do not know where this is wrong.
I did not get any errors.
The login page is in index.php, and when you sign in, and everything is fine (no errors / wrong PWs etc.), then you should get home. Will be redirected to.
This is not the case. When I log in, it refreshes index.php again and outputs it at the top:
Warning: header information can not be modified - headers already (httpd .www / oBz / index.php: 2)
There is httpd.www / oBz / index.php
on line 221: Title ("Location: home .php ");
Okay, so I went home to enter the Php manually, now at home.php I am at the top:
Include 'dbc.php' ; Page_protect (); Echo "Hello World";
page_protect Check if a session is set or cookie (I remember), but if something is set then you will be content "hello world" and you will not be used.
But right now I get this bus when I enter home.php:
P> line 69 theresWarning: session_start () [function.session-start]: session Can not send cookies - Headers that have already been sent (output starts at Httpd.www / oBz / dbc.php: 29) httpd.www / oBz / dbc.php line 69
Warning: session_start () [ Function.session-start]: The session can not send the cache limiter - the header has already been started at Httpd.www / oBz / dbc.php: 29) httpd.www/OBz/dbc.php on line 69
Warning: header information can not be modified Heads have already been sent (output has been started at httpd.) On www / oBz / dbc.php: 29) at line 117 on httpd.www / oBz / dbc.php
session_start ()
, and this is the function page_protect ()
; The first line in the line 117 theres header ("location: index.php")
and if you are not logged in (session set / cookie set) is to redirect < / P>
I hope the information has been provided, if not just comment on your comment, and I will try to fulfill it ..
thanks
< P> Update:Here is DBCPP:
** Index.php where you log in and where the session sets
** Update: Now I have Fear warnings / errors have been solved, but this was not the solution to the session issue!
* * Update: phpbin.net/x/25857430 Updated dbc.php, all html which was previously in dbc.php is a new file in top.php. I include the top.php file after the doLogin function section in index.php, so there is no error with headers. *** Update: The problem is somewhere: so its redirection I have already sent the output to the browser with that browser in my index.php
Which is present before your first PHP.
You need to rearrange the code so that any headers needed to be sent before it is sent to the browser.
Like this:
The simplest answer may be to transfer all of the HTML after the PHP code. Call logout
function and the second is session_start ()
.
For that matter anyway, why is there any HTML in this file? Beyond the session tasks, I noticed at least 2 headers ()
calls.
Update:
if (Isset ($ _COOKIE ['user_id']) and isset ($ _COOKIE ['user_key'] ) / / We double check the cookie termination time against the stored in the database / I / I to snipped a bunch of code to indicate what is happening here} and {header ("location: index.php"); Die (); }
Therefore, if the cookie values are not present, then what happens here?
Comments
Post a Comment