Sessions expiring -> quick fix?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Sessions expiring -> quick fix?

Post by seodevhead »

I am starting sessions when user's register a username and login (so it remembers them), however after a couple weeks, I notice the session ends and I have to login again. I want to set the sessions so that they never expire or at least expire after a very long time (kinda like vBulletin, phpBB, Yahoo!, etc). This is the session start I am using... what do I need to change/add to get this to work right? Thanks!

NOTE: My login.php assigns the session variables correctly :)
BELOW: the code below is in the header file of every php page.

Code: Select all

session_set_cookie_params (60*60*24*10000, '/', 'www.mywebsite.com');
session_start();
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

sessions that last a couple weeks? I'd hate to be your host/server admin :/

use cookies to identify the user and and to "log them in" automatically if they so wish - don't use, or expect to use sessions for more than say an hour tops. They are called sessions to represent variables that are to remain persistant per 'session' of the user sitting at their pc.
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

So I guess setcookie() is the function I need to use instead of session_set_cookie_params() like I had??? Thanks!
Post Reply