473,396 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Session

I dont think I am doing this correctly. Sorry I am a newby..

I can get it to login and display the username, but if you leave the page and come back to it.. it wont show the username again of the person who just loged in. I dont think the cookie is being set correctly.


Here is the code that I am using...

[php]

if ($mode == 'login')
{
post('un,up');
$unn = mysql_escape_string($un);
$upp = mysql_escape_string($up);
$qc = mysql_query("SELECT * FROM `instructors` WHERE `username` = '$unn' AND `password` = '$upp' AND `isadmin`='1'"); if (mysql_num_rows($qc) > 0)

{

$rc = mysql_fetch_assoc($qc);
extract($rc);
$logged = 1;
session_register('logged');
$_SESSION['logged'] = $id;
session_register('MyID');
$_SESSION['MyID'] = $id;
$mode = '';
}

else $error = "<span class='text'><font color=red>Incorrect login information</font></span>";
}



if (!isset($_SESSION['logged']))
{
include ("navtop.php");
include ("nav.php");


echo "
[/php]

Thanks
Apr 25 '08 #1
8 1351
ronverdonk
4,258 Expert 4TB
Your code does not contain any echo of the username, so?

Ronald
Apr 25 '08 #2
realin
254 100+
and do we really need to use session_register() ??
Apr 27 '08 #3
ronverdonk
4,258 Expert 4TB
and do we really need to use session_register() ??
No you do not. Don't use it, use $_SESSION and do not forget to start every script using $_SESSION with session_start().

Let me show some thoughts from the php documentation on this.
If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.

If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register.
Ronald
Apr 27 '08 #4
realin
254 100+
No you do not. Don't use it, use $_SESSION and do not forget to start every script using $_SESSION with session_start().

Let me show some thoughts from the php documentation on this.Ronald
yup, this is what i have been thinkin, cause session_register() was a way old thing, but i din know the above mentioned fact about registering globals, thanks Ronald, you always add up my knowledge base :)
Apr 27 '08 #5
ronverdonk
4,258 Expert 4TB
So what has the OP, nathanwb, to say about this? Any solution in sight?

Ronald
Apr 27 '08 #6
Sorry for the delay in responding.. I went to books a million and got a book :)

I have solved the issue, thanks for the imput though.
Apr 30 '08 #7
TheServant
1,168 Expert 1GB
Sorry for the delay in responding.. I went to books a million and got a book :)

I have solved the issue, thanks for the imput though.
Was it including session_start()?
Apr 30 '08 #8
ronverdonk
4,258 Expert 4TB
Sorry for the delay in responding.. I went to books a million and got a book :)

I have solved the issue, thanks for the imput though.
Please share ýour solution with us, so we can learn from it.

Ronald
Apr 30 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals...
1
by: mudge | last post by:
I'm running PHP Version 4.3.10. I'm trying to make it so that when a person logs in using a user name and password that their session is valid and continues for a few months so they don't have to...
6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
5
by: Abhilash.k.m | last post by:
This is regarding the session management using Out of proc session management(SQL SERVER). Among the samples below which one is better to set the session? 1. There are 20 session...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
14
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and...
7
by: aroraamit81 | last post by:
Well Guys, Here is a very strange trouble. When more than one users request tto same page at the same time then our session gets conflicted. Moreover I printed my SessionID, strangely but true I...
0
by: TRB_NV | last post by:
I'd been using an Access database based shopping cart, but wanted to change it so that it would use session variables. I have a form that's submitted to a page called addtocart.asp that contains...
1
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking...
5
by: lyealain | last post by:
<% If Session("username") = "" Then Response.Redirect("/CLS/Login.asp") End If Dim conn Dim connectstr Dim db_name, db_username, db_userpassword Dim db_server Dim res
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.