473,395 Members | 1,678 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,395 software developers and data experts.

session user_id

Hi all.

I have been reading notes on how to use sessions and cookies,I see that there is a user_id which is used to identify each user but dont see how it is generated and assigned to a particular user.

Does anyone have a clear explanation on how its generated coz even on the insertstatement it is not there on the values??
Jan 29 '07 #1
4 2993
Motoma
3,237 Expert 2GB
Hi all.

I have been reading notes on how to use sessions and cookies,I see that there is a user_id which is used to identify each user but dont see how it is generated and assigned to a particular user.

Does anyone have a clear explanation on how its generated coz even on the insertstatement it is not there on the values??
User IDs are usually generated by the database when a user is created by having a NOT NULL AUTO_INCREMENT field in the table.
They are usually grabbed from a database when a user logs in.
Jan 29 '07 #2
User IDs are usually generated by the database when a user is created by having a NOT NULL AUTO_INCREMENT field in the table.
They are usually grabbed from a database when a user logs in.
Thanks for responding.

that is exacly what I dont under stand the id I have been using is the aouto increment which starts from 1,2,3 goes on ,is it the same how do I link it to the username I just dont get the logic I guess.
Jan 29 '07 #3
Motoma
3,237 Expert 2GB
Thanks for responding.

that is exacly what I dont under stand the id I have been using is the aouto increment which starts from 1,2,3 goes on ,is it the same how do I link it to the username I just dont get the logic I guess.
When you insert an user into a user table with an autoincrement field, it will get assigned an ID (the next number in the sequence) . When you check to see if a user exists, you will grab the id as well as the user information:
Expand|Select|Wrap|Line Numbers
  1. SELECT user_id FROM userTable WHERE username='mankolele' and password='toasty';
  2.  
Hope this helps.
Jan 29 '07 #4
Atli
5,058 Expert 4TB
$_Session['user_id'] is not something that exists by default. It has no connection to any database or anything else.
It is simply a variable, like $user_id, except it is stored in the _Session array.
It doesnt have to be user_id, it could be i_am_bob and the php script wouldnt give a frick.
If you want to use it, you have to create it and give it a value, just like any variable.

User id's are passed in the _Session array pretty frequently and most coders try to use variable names that clearly identify what they represent, so it is not uncommon to see user id's stored as user_id or UserID or something simular.
Jan 30 '07 #5

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

Similar topics

2
by: sumdumgaitu | last post by:
I'm using the following code for a login page in PHP. Everything works OK until someone else logs in from the same browser. As best I can tell $mail, $password, and $user_id are not getting...
9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
3
by: Peter Theill | last post by:
Hi, I'm trying to include the content of a request into an Xml document: if (System.Web.HttpContext.Current.Session != null) { XmlDocument d = new XmlDocument(); d.Load(new...
5
by: Åženol Akbulak | last post by:
Hello; I use in my web application FormsAuthentication. Also I use Session state (InProc). When a user logged in, I can read Session parameters. (For example Session). Problem is that, when...
5
by: google | last post by:
I have a website that has a asp secured members only aria that keeps session variables to check if someone is logged in or not (if session variables are not there then redirect to logon screen) but...
2
by: weird0 | last post by:
I am trying to display a crystal report in .aspx page. I created a dataset for that but i wrote the query: SELECT atm_amount,atm_branch,atm_date,balance FROM ATM_Transactions WHERE...
12
by: MrHelpMe | last post by:
Hello again all, I've finished my whole application and now I don't like the whole session variables that I am using. I have a form, user fills in info clicks submit and using CDOSYSMail an...
8
by: pim | last post by:
Dear All, What I was wondering is how safe it is to store user_id or username or anything like that in session. I usualy store a bunch of info in a session so I do not need to search the...
0
by: d0353101 | last post by:
I am having login.cgi. user enter id and password. if ok it redirects to main.cgi with user_id as main_page.cgi?user_id=$user_id. main.cgi is having left menu and right part is for doing some...
7
by: lak | last post by:
I want to study about the Session handling in PHP. I don't know where to start. So please suggest me some way.
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.