Page 1 of 1

set session?

Posted: Sun Jun 17, 2012 9:05 pm
by jayson.ph
hi all,

i have code for login.php below and it work okay and i get in. but my problem now is where should i put the session code to start and to destroy it:
into page: branch_view.php or
here in login.php

Code: Select all

$pingsql = "SELECT * FROM tbl_user WHERE usr_name = '$valusename' AND usr_pass = '$valpasswrd'"; 
	$pingresult = mysql_query($pingsql); 
	$pingrowscount = mysql_num_rows($pingresult);
	if($pingrowscount == 1)
	{
	session_register('usr_name');
	session_register('usr_pass');
	header('Location:../public-functions/branch_view.php');
	}
	else
	{
	header('Location:../login_function/error_login_function/logerror.php');


Please help

Re: set session?

Posted: Mon Jun 18, 2012 12:40 am
by social_experiment
session_start() always goes at the top of the page;

viewtopic.php?f=28&t=135287
Have a look at this tutorial about where to regenerate a new and destroy the old session. Avoid using session_register();
The Manual wrote: This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.

Re: set session?

Posted: Mon Jun 18, 2012 1:01 am
by jayson.ph
[text]Avoid using session_register();[/text]

Why?

Re: set session?

Posted: Mon Jun 18, 2012 1:16 am
by social_experiment
It's deprecated as of php 5.3 meaning it is no longer used by php. If you use it and the code is on a server running php 6 the variables won't be registered

Re: set session?

Posted: Mon Jun 18, 2012 1:27 am
by jayson.ph
Ah Okay Thank you for the information.

Re: set session?

Posted: Mon Jun 18, 2012 1:35 am
by jayson.ph
one question please, i already set session_destroy but somehow when i click back button from the browser. i get in without signing in into log-inform. why? what should i use?

Re: set session?

Posted: Mon Jun 18, 2012 2:08 am
by social_experiment
what does the code that checks if a user is logged in look like