PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Dec 22, 2014 9:52 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: set session?
PostPosted: Sun Jun 17, 2012 9:05 pm 
Offline
Forum Contributor
User avatar

Joined: Mon Jan 02, 2012 10:20 am
Posts: 165
Location: MP
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
Syntax: [ Download ] [ Hide ]
$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


Top
 Profile  
 
 Post subject: Re: set session?
PostPosted: Mon Jun 18, 2012 12:40 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2775
Location: .za
session_start() always goes at the top of the page;

http://forums.devnetwork.net/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.

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
 Post subject: Re: set session?
PostPosted: Mon Jun 18, 2012 1:01 am 
Offline
Forum Contributor
User avatar

Joined: Mon Jan 02, 2012 10:20 am
Posts: 165
Location: MP
Syntax: [ Download ] [ Hide ]
Avoid using session_register();


Why?


Top
 Profile  
 
 Post subject: Re: set session?
PostPosted: Mon Jun 18, 2012 1:16 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2775
Location: .za
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

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
 Post subject: Re: set session?
PostPosted: Mon Jun 18, 2012 1:27 am 
Offline
Forum Contributor
User avatar

Joined: Mon Jan 02, 2012 10:20 am
Posts: 165
Location: MP
Ah Okay Thank you for the information.


Top
 Profile  
 
 Post subject: Re: set session?
PostPosted: Mon Jun 18, 2012 1:35 am 
Offline
Forum Contributor
User avatar

Joined: Mon Jan 02, 2012 10:20 am
Posts: 165
Location: MP
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?


Top
 Profile  
 
 Post subject: Re: set session?
PostPosted: Mon Jun 18, 2012 2:08 am 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2775
Location: .za
what does the code that checks if a user is logged in look like

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group