Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Need learn UserID in external script

Quote Reply
Need learn UserID in external script
It is necessary to read through from other script SessionID both to learn UserID, and to add new record to base with UserID.
How optimum it to make?

(The script and db.cgi is in one dir)
DBMan SQL 2
Quote Reply
Re: [Printsite] Need learn UserID in external script In reply to
Hi,
Can you give a few more details?
Do you want to use the session id and user id from DBManSQL in another script?
OR
Do you want to use the session id and user id from another script in DBManSQL?
Simon.
Quote Reply
Re: [jai] Need learn UserID in external script In reply to
>>> Do you want to use the session id and user id from DBManSQL in another script?
Yes. Necessary to receive UserID in other scripts...

I.e. it is necessary to read through open session from cookies and to make query to user table...
Quote Reply
Re: [Printsite] Need learn UserID in external script In reply to
With limited details it's difficult to help you but you could parse the UserId (and any other variables) to another script by using something like the following in your sub (or plugin) -

print "Location:http://www.yourdomain.com/cgi_directory/script_name.cgi?UserId=$tags->{UserId}&other_name=$tags->{variable_name}\n\n";

Your other script would need to process the input.

Last edited by:

jai: Sep 30, 2004, 7:32 AM
Quote Reply
Re: [jai] Need learn UserID in external script In reply to
Thanks, but it not that is necessary.

I want from own script:
1) Connect module GT
2) Read through cookies with sid (SessionID)
3) Make inquiry and to receive UserID
4) Make record in base with UserID

Probably it?
Quote Reply
Re: [Printsite] Need learn UserID in external script In reply to
Sorry,
Maybe someone else can understand better what you are trying to do but I need more details (e.g Which variables do you have and which variables do you want to pull from the database? Are you only wanting one row from the database or multiple rows?).
This seems more of a general perl or MySQL problem rather than a DBManSQL problem if you are only querying the database from an external script.

Last edited by:

jai: Sep 30, 2004, 4:21 PM
Quote Reply
Re: [jai] Need learn UserID in external script In reply to
I want to use library GT in the my scripts?
How it to make?

1) It is necessary to read through cookies c sid.
2) To make inquiry to table Sample_Users_Sessions and to receive session_user_id (We learn on session - UserID)
Quote Reply
Re: [Printsite] Need learn UserID in external script In reply to
You still haven't given enough details to understand what you are trying to do.

Quote:
I want to use library GT in the my scripts?
I'm not sure, but I don't think (licence/copyright wise) you are allowed to pull out parts of the GT library to use in your own scripts. Someone from GT will be able to advise you better.


Quote:
To make inquiry to table Sample_Users_Sessions and to receive session_user_id
Try something like -

###assign the UserID from your external script
my $UserID = "$user_id_value";

###set your database details
my @db_connect = ("DBI:mysql:database_name", "user_name", "password");

###connect to the DBMan SQL database
$DBH = DBI->connect (@db_connect) or die ("Content-type: text/html\n\n Could Not Connect");


###do your query
$query = qq!
SELECT session_id
FROM Sample_Users_Sessions
WHERE session_user_id = $UserID
!;
my $sth = $DBH->prepare ($query) or die ("Content-type: text/html\n\n Could Not Prepare");
$sth->execute or die ("Content-type: text/html\n\n Could Not Execute");

###do somthing with what you find
if ($sth->rows) {
#Do something here
$sth->finish;
# Disconnect
$DBH->disconnect();
exit;
}

else {
#do something else
$sth->finish;
# Disconnect
$DBH->disconnect();
}

You need to replace the red parts with your own values.
As I said before, this seems to be a Perl/MySQL question.
Simon.