how can i set limit to my sessions in php so that if a page remains idle for certain time, the user is logged out?

session_start();
setcookie("PHPSESSID",$_COOKIE['PHPSESSID'],time()+1800);

Where 1800 is the time in seconds before the session should expire. PHPSESSID is the default session ID. This way, every time a user loads a page they get their session extended.

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.