brown2005 Posted August 30, 2006 Share Posted August 30, 2006 Hi, Can I use both together....i mean i have now login_process.phpi have lines like$_SESSION['MemberID'] = $login_array['members_id'];session_register('MemberID'); and in session.php which calls all the information i have $session_sql = "SELECT * FROM members WHERE members_id = '$_SESSION[MemberID]'";$session_result = mysql_query($session_sql) or die(mysql_error());$session_array = mysql_fetch_array($session_result);$session_id = $session_array['members_id'];$session_member = $session_array['members_username'];now obviously when u close ur browser it deletes the session... but i want to know if i can have say a tick box on the login form which people can tick to stay logged in and set a cookie to be used with the above, or any better ideas...thanks Link to comment https://forums.phpfreaks.com/topic/19170-using-php-sessions-and-cookies/ Share on other sites More sharing options...
onlyican Posted August 30, 2006 Share Posted August 30, 2006 yesI do the sameMost sites, with remember me doesOn mine, if they log in (checked and details ok) then session is createdif the have ticked the remember me box then a cookie is placed for 10 days Link to comment https://forums.phpfreaks.com/topic/19170-using-php-sessions-and-cookies/#findComment-82999 Share on other sites More sharing options...
brown2005 Posted August 31, 2006 Author Share Posted August 31, 2006 can u show me how to do it then please? Link to comment https://forums.phpfreaks.com/topic/19170-using-php-sessions-and-cookies/#findComment-83392 Share on other sites More sharing options...
Jenk Posted August 31, 2006 Share Posted August 31, 2006 [code]<?phpsession_start();$_SESSION['variable'] = 'foobar';?>[/code]That's all you need to start a session and to assign a session variable, php does the rest for you.Just remember to have session_start(); at the top of every page before _any_ output is produced, and the session data, if still valid, will be accessible via $_SESSION superglobal. Link to comment https://forums.phpfreaks.com/topic/19170-using-php-sessions-and-cookies/#findComment-83402 Share on other sites More sharing options...
brown2005 Posted August 31, 2006 Author Share Posted August 31, 2006 sorry i mean, how can i set the cookie if a check box is ticked..... that can be used with php sessions Link to comment https://forums.phpfreaks.com/topic/19170-using-php-sessions-and-cookies/#findComment-83428 Share on other sites More sharing options...
onlyican Posted August 31, 2006 Share Posted August 31, 2006 [code]<lable><input type='checkbox' name='rem_me' value='on' />Remember Me</label><?php//then in your codeif($_POST["rem_me"]){set_cookie(.....}[/code] Link to comment https://forums.phpfreaks.com/topic/19170-using-php-sessions-and-cookies/#findComment-83431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.