0

I am trying to save sessions but it doesnt. After refreshing it just disappears just like a post.

This is my script

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>";
    }
}

s

ession
Session Support     enabled
Registered save handlers    files user sqlite
Registered serializer handlers  php php_binary wddx

Directive   Local Value Master Value
session.auto_start  Off Off
session.bug_compat_42   On  On
session.bug_compat_warn On  On
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_httponly Off Off
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  100 100
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 4   4
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   C:/Users/ADMINI~1/AppData/Local/Temp/3  C:/Users/ADMINI~1/AppData/Local/Temp/3
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    Off Off
session.use_trans_sid

0   0

It does work on my laptop, where I do not use appserv. Does anyone know the solution?

Sinan Samet
  • 6,432
  • 12
  • 50
  • 93
  • Are you calling [`session_start()`](http://www.php.net/manual/en/function.session-start.php) somewhere earlier? – John C Jul 30 '12 at 01:25
  • Yes I am using it in another file where I include this file I am sure its not my coding but my settings in perhaps apache – Sinan Samet Jul 30 '12 at 02:45
  • Server trouble shooting is trickier - have a look at some of the answers to [this question](http://stackoverflow.com/questions/155920/php-session-data-not-being-saved) to see if you have a similar problem. – John C Jul 30 '12 at 02:57
  • My temp map should be writable so I dont think thats the problem but I did add my session information for if its usefull – Sinan Samet Jul 30 '12 at 03:40
  • I changed the path anyway and checked the folder. It has session files in it so it should be working fine. But sessions still dont work on my server. When I refresh its just gone. Just like a POST. – Sinan Samet Jul 30 '12 at 11:38
  • Did you try setting it somewhere outside of the user directory (this can be a problem http://serverfault.com/a/298849)? Also try keeping an eye on your cookies (Firebug is helpful for this) to make sure they are being set and kept correctly. – John C Jul 31 '12 at 02:33

1 Answers1

0

I believe John C got the problem.
As a complementary information, you should use else instead of "if($countrows != 1)".

Jerska
  • 11,722
  • 4
  • 35
  • 54