|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
session_set_cookie_params()
Hi peoples,
I was just wondering if you could help me with yet ANOHTER problem! >.< With my website, I want to make it that you don't have to login UNLESS you logout, even after u restart ur computer etc. BUT with my webhost, I can't edit the php.ini SO I have tried using something like: session_start(); session_set_cookie_params ("Sat Dec 4 11:55:15 MST 2010"); session_register("session"); or session_start(); session_set_cookie_params ("315360000"); session_register("session"); and surely enough if I close my browser and restart it within a certain amount of time (I'm not sure how long, maybe an hour or something but definitely not 10 years, or till the year 2010), it'll remain logged in, but any longer than that, and I'll have to relogin. Can anyone please tell me what I'm doing wrong? Thanks. |
|
#2
|
|||
|
|||
|
Well for that purpose use setcookie() instead, sessions are best for per one session and not for remembering a user.
// One month cookie set setcookie ( 'user', $userval, time() + 60*60*24*30 ); $user = $_COOKIE['user']; |
|
#3
|
|||
|
|||
|
why doesn't it work the way I tried it though?
|
|
#4
|
||||
|
||||
|
As Mike_r said, sessions are for one session. If you close your browser or idle for long enough for your session to time out, the session cookie expires. In order to maintain state across sessions and browser closings, you have to use cookies. Sessions are for one thing; cookies are for another; the thing you're wanting to do simply requires cookies rather than sessions.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > session_set_cookie_params() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|