Jump to content

Dynamically Handling userIDs


proggR

Recommended Posts

I'm trying to create a simple chat script using AJAX. I've been hacking around with code someone published alongside a tutorial and I've been able to figure out how it works in as far as the tutorial covers and a little bit more. What I want to add now though is automatically assigning an id to each user. The id will auto increment with each added user but in the event that a user logs off, the id becomes available again and the next user to log on will get that id. This way users can interact with each other directly without having to type in long misspelled user names. I'm going to keep searching but so far I haven't had much luck. I'm probably Googling the wrong thing but I thought someone here could get me on track.

Thanks in advance.

Link to comment
Share on other sites

Not sure why you need the id to become available again.

I assume there is no signing up just allocating ids for the session. Still there will need to be some sort of human readable identifier for those in the chat.

That's right, there is no signup. Or at least the majority of users wouldn't be signed up. I may offer a signup service to reserve names/ids but that's later.

And that's correct as well that ids are just for the session. A similar chat site is teenchat. I like a lot of things about their site but I don't like a bunch and there are features missing that I want to add to a chat as well. Its really just for a project to keep busy. Nothing I'd expect to launch publicly I don't think but who knows.

Basically I'm wondering how to handle session only ids within a database. Should I have it all handled by the PHP scripts maybe and have the primary key be for the user name instead. I suppose that would all the difficulties away. How would be a good way to index it in order for the script to find open ids the fastest. I imagine scanning the database for an open id, especially when it wouldn't be organized by that id, will take a little more processing time than I wanted.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.