session not keeping user logged in

Reply

Join Date: Apr 2008
Posts: 5
Reputation: ZaphodQB is an unknown quantity at this point 
Solved Threads: 0
ZaphodQB ZaphodQB is offline Offline
Newbie Poster

session not keeping user logged in

 
0
  #1
Apr 24th, 2008
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)

  1. <?php
  2. $ses="MYSID";
  3. $sesTime=60*1;
  4. session_set_cookie_params ($sesTime);
  5. session_name($ses);
  6. session_start();
  7. if($_POST[mode]=="LogOut"){
  8. $_SESSION=array();
  9. session_destroy();
  10. session_set_cookie_params ($sesTime);
  11. session_name($ses);
  12. session_start();
  13. }
  14. if(isset($_COOKIE[$ses])){if(setcookie($ses,$_COOKIE[$ses], time()+$sesTime, "/")){echo "reset cookie";}}

Anyone explain where I am fuddling this up?
Last edited by ZaphodQB; Apr 25th, 2008 at 12:13 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 5
Reputation: ZaphodQB is an unknown quantity at this point 
Solved Threads: 0
ZaphodQB ZaphodQB is offline Offline
Newbie Poster

Re: session not keeping user logged in

 
0
  #2
Apr 25th, 2008
Originally Posted by ZaphodQB View Post
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)

  1. <?php
  2. $ses="MYSID";
  3. $sesTime=60*1;
  4. session_set_cookie_params ($sesTime);
  5. session_name($ses);
  6. session_start();
  7. if($_POST[mode]=="LogOut"){
  8. $_SESSION=array();
  9. session_destroy();
  10. session_set_cookie_params ($sesTime);
  11. session_name($ses);
  12. session_start();
  13. }
  14. 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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 28
Reputation: vinothkumarc is an unknown quantity at this point 
Solved Threads: 3
vinothkumarc vinothkumarc is offline Offline
Light Poster

Re: session not keeping user logged in

 
0
  #3
Apr 25th, 2008
I think... wt u hv expressed is 100% correct
Thanks & Regards,
VinothKumar C
post2vinoth@gmail.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC