Just doing a basic forum with a python file allowing the user to login and/or create an account. Thought I would do a little bit more and have each user logged in with thei
I think this might work
from socket import gethostname, gethostbyname
ip = gethostbyname(gethostname())
or If you are using CGI you can get it from the REMOTE_ADDR
environmental
variable
It sounds like you're running this as a CGI script. The user's IP address will be in the REMOTE_ADDR
environment variable, os.environ["REMOTE_ADDR"]
.
Are you assuming each user has a unique IP address? If so, this is not a good or safe way to generate a UserID. In any online community, there will always be some users accessing your site via gateways or proxy servers, so some users will have the same remote IP address.
You could append some random number or timestamp to the IP address, or just use a datetimestamp. But why not just use the user's email address?
HTH