I have a web page which I can login to with a user name and password and when the page reloads of the first time after the signin the session loads and has my status correct but just navigating to another page (all done through the same php file with includes later in the file) the session fails and I am back to an anonymous (unlogged in) visitor.
Here is the logic (note $sesTime is set to 1 min for testing)

<?php
$ses="MYSID";
$sesTime=60*1;
session_set_cookie_params ($sesTime);
session_name($ses);
session_start();
if($_POST[mode]=="LogOut"){
    $_SESSION=array();
    session_destroy();
    session_set_cookie_params ($sesTime);
    session_name($ses);
    session_start();
}
if(isset($_COOKIE[$ses])){if(setcookie($ses,$_COOKIE[$ses], time()+$sesTime, "/")){echo "reset cookie";}}

Anyone explain where I am fuddling this up?

I have a web page which I can login to with a user name and password and when the page reloads of the first time after the signin the session loads and has my status correct but just navigating to another page (all done through the same php file with includes later in the file) the session fails and I am back to an anonymous (unlogged in) visitor.
Here is the logic (note $sesTime is set to 1 min for testing)

<?php
$ses="MYSID";
$sesTime=60*1;
session_set_cookie_params ($sesTime);
session_name($ses);
session_start();
if($_POST[mode]=="LogOut"){
    $_SESSION=array();
    session_destroy();
    session_set_cookie_params ($sesTime);
    session_name($ses);
    session_start();
}
if(isset($_COOKIE[$ses])){if(setcookie($ses,$_COOKIE[$ses], time()+$sesTime, "/")){echo "reset cookie";}}

Anyone explain where I am fuddling this up?

Never mind I figured out what was wrong, it should have been;
$sesTime=time()+60*1;
in line 3

I think... wt u hv expressed is 100% correct

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.