Sinan Posted July 30, 2012 Share Posted July 30, 2012 The sessions do save I have checked the directory, but somehow it doesnt work at all. I cannot call the session after going to another page. I am sure the code is correct I have tested it on many ways. It must be my PHP or apache settings but I have no idea what and where it is. Quote Link to comment Share on other sites More sharing options...
trq Posted July 30, 2012 Share Posted July 30, 2012 Post your problematic code. Quote Link to comment Share on other sites More sharing options...
Sinan Posted July 30, 2012 Author Share Posted July 30, 2012 <?php $login = file_get_contents("tpl/contents/login.html"); if(isset($submitlogin)){ //Query setup $loginquery = "SELECT UserID, Password FROM Login WHERE UserID='".mssql_real_escape_string($username)."' AND Password='".$password."'"; $loginresult = mssql_query($loginquery); $countrows = mssql_num_rows($loginresult); if($countrows == 1){ $_SESSION['username'] = $username; $_SESSION['password'] = $password; } if($countrows != 1){ $login .= "<span style='color:red'>Login Failed</span>"; } } echo $_SESSION['username']; //Get template $template = str_replace("%ucp%", $login, $template); ?> Its included in a file where session_start(); has been used and I tested it with other ways too like <?php $_SESSION['username'] = "test"; echo $_SESSION['username']; ?> When I remove $_SESSION['username'] = "test"; It doesnt echo it anymore Quote Link to comment Share on other sites More sharing options...
Christian F. Posted July 30, 2012 Share Posted July 30, 2012 Try to make a new file, put the following code into it, and see what it returns: <?php session_start (); var_dump ($_SESSION); If it returns with undefined variable, then your session handler is not starting (or you have some other configuration issue). On the other hand, if it returns an empty array, then I suspect the problem is with the session cookie and/or session ID not being recognized. Quote Link to comment Share on other sites More sharing options...
Sinan Posted July 30, 2012 Author Share Posted July 30, 2012 array(0) { } Thats what it returns I am almost sure it must be in the PHP settings but I dont know what exactly it is. It works on my laptop where I have set up my own webserver. But on the VPS (where the problem happens) I use appserv. And I used to have it earlier with appserv and he changed it either in the apache or php settings 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.