CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Create a custom session variable in ASP

Print topic Send  topic

Author Message
DJJWP


Posts: 77
Posted: 08/18/2009, 8:12 PM

Trying to follow the lead of others I attempted to create a session variable as below...

Dim Connection1 If Login_DoLogin_OnClick = True Then      
Set Connection1 = New clsDBConnection1      
Connection1.Open      
Session("mailstop") = CCDLookUp("mailstop","contacts","ID="& Connection1.ToSQL(CCGetUserID(),ccsInteger), DBNetops)      
Connection1.Close      
Set Connection1 = Nothing End if

This was placed into the Client On Click as custom code. I have also tried to add it to the server side and that did not work as well.

'ID' is the key field and index of the table 'contacts' and the "UserID" in the project.

I get no errors and I get no new session variable.

Using: IIS & MySQL

What am I missing here?

_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 08/26/2009, 3:25 PM

could you explain what are you trying to do.

also to be sure that teh execution is running that part of the code

add something like

aftther the end if

RESPONSE.WRITE "I WAS HERE " & session("mailstop")
RESPONSE.END


(if there are any kind of error you will gettit easy







_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DJJWP


Posts: 77
Posted: 08/28/2009, 5:54 PM

I found the solution and will post it Sunday when I get back to work. Thanks
_________________
Network Operations Rule
View profile  Send private message
DJJWP


Posts: 77
Posted: 09/08/2009, 3:05 PM

Solution:
Under the Login button events, add a "custom code" to the server on click event.

'Custom Code @24-73254650  
' -------------------------  
Dim Connection1        
Set Connection1 = New clsDByourDBname  
Connection1.Open       
Session("mailstop") = CCDLookUp("mailstop","contacts","ID="& Connection1.ToSQL(CCGetUserID(),ccsInteger), Connection1)  
Connection1.Close        
Set Connection1 = Nothing  
' -------------------------  
'End Custom Code

The above code created a "mailstop" session variable from the database yourDBname, contacts table.
_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 09/11/2009, 6:10 AM

ah now i know what you were trying to do.
also you dont need to create a new connection.

Session("mailstop") = CCDLookUp("mailstop","contacts","ID="& DBConnection1.ToSQL(CCGetUserID(),ccsInteger), DBonnection1) 

maybe you could try to use just one line.
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DJJWP


Posts: 77
Posted: 09/11/2009, 9:12 AM

Will give it a try. Too bad there is not a GUI for doing such a simple task in CCS. Some day maybe...
_________________
Network Operations Rule
View profile  Send private message
DJJWP


Posts: 77
Posted: 10/13/2009, 7:13 PM

Ran is to a small issue. Every once in a while the user gets all their session variables except this one (mailstop) so this works but has not been bullet proof.

Does anyone have an idea as to why this may happen?

I also want session variables to not time out for over 16 hours. Can that be done? I keep getting prompted for log on far too often. (time out resolved)
_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 10/18/2009, 5:50 PM

also i really dont know why you need to save the email in a session varibale

if you need to send an email just call the function before send the email (maybe)




to keep the section
1) create a smail ASP hidden in a Iframe (with auto refresh) work perfect
2) save varibale on cookies and getback if session is null
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DJJWP


Posts: 77
Posted: 10/26/2009, 4:02 PM

For some reason if the session variable "Mailstop" (IDs where the user is by their building code) is created on the logon.asp page and not the common.asp page, it fails to populate the session variable in IE6. The userid, groupid, and logonid all come from the common.asp page. This is not e-mail I'm trying to save but a location identifier which is formatted like "P1-XXTD-02-1".

When I tried to copy the groupid process in common and add mailstop it blew up.

I found also that it fails only in IE. Firefox always works.

Any suggestions?
_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 10/29/2009, 8:05 PM

really odd
you must be doing something wrong.

the only you need to get the email of the user in session is :

vEmail=ccdlookup("UserEmail","Usertable","userid=" & ccgetuserid(),DBConnection1)

that's all, do this before send the email.

you dont need to copy any code from common.asp nither modify the common.asp
or i really dont udnertand your issue :(

_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DJJWP


Posts: 77
Posted: 10/30/2009, 9:21 AM

This has nothing to do with email.

It is the creation of a session variable that in IE times out in 20 min while the variables in common.asp (UserID, GroupID, LogonID) do not.

mailstop refers to a building identifier, not a e-mail address.

If the user is using IE, after 20 min of inactivity, the variable times out and they can not add records to the system as it is a required hidden field. The server and the project are both set to 1440 for timeout.

_________________
Network Operations Rule
View profile  Send private message
peterr


Posts: 5971
Posted: 10/30/2009, 10:09 AM

Hi,

Quote DJJWP:
When I tried to copy the groupid process in common and add mailstop it blew up
Someone may be able to help if you describe the "blew up".
Though generally it doesn't matter if a session variable is created in a specific page or common files.

Quote DJJWP:
The server and the project are both set to 1440 for timeout.
Could you describe where how did you set it?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
DJJWP


Posts: 77
Posted: 10/30/2009, 4:50 PM

Blew up -> threw a generic vb script error and failed to load. I think I may have had something wrong on the page and missed copying the right items and figured it may be a bad idea to edit that page by hand anyway and changed it back.

I set the session time on the common.asp page where session timeout is listed. I will get a copy of where when I get to work Sunday.

I set the session time out as well in the IIS server config.

_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 10/31/2009, 12:18 PM

Could you post what you modify or copy.

Another thing.... Are you using remember. me login feature?

_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Oper


Posts: 1190
Posted: 10/31/2009, 1:19 PM

Could you post what you modify or copy.

Another thing.... Are you using remember. me login feature?

_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DJJWP


Posts: 77
Posted: 11/01/2009, 2:00 PM

Yes, I have the remember me feature enabled but that is another issue... even when I go to different pages, I get prompted for logon. It has been this way since I started this project which was before that feature was in the CCS program. It was enabled with defaults.

'Custom Code @24-73254650 ' -------------------------     
Dim Connection1       
Set Connection1 = New clsDBNetops        
Connection1.Open        
Session("mailstop") = CCDLookUp("mailstop","contacts","ID="& Connection1.ToSQL(CCGetUserID(),ccsInteger), Connection1) 	   
Session.Timeout = 1440 	   
Connection1.Close       
Set Connection1 = Nothing    
'  ------------------------- 'End Custom Code

I added the session time out here in hopes that it would pick it up but it has not worked and will be removed.

The second place it is set is in Common.asp
Line 48

'Session.Timeout = 480  remarked out  
Session.Timeout = 1440

The third and final place I set it was on the IIS server

Using the sites properties / Home directory / Configuration / Options / Application Configuration / Enable session state / session time out is set to 1440.

Attempt in common.asp, I backed that off and do not have a complete record of what I tried there.

This is the area I changed in common.asp and it may now works to get the variable but I have to see now if the users are still having the time out issue.

I have seen though in other postings that changing this file in not a good idea:

''CCLoginUser @0-3AA2987D  
Function CCLoginUser(Login, Password)  
    Dim Result  
    Dim SQL  
    Dim RecordSet  
    Dim Connection  
    Dim UserIDField  
    Dim GroupIDField  
	Dim mailstopField 'added  
      
    Set Connection = New clsDBNetops  
    Connection.Open  
    'SQL = "SELECT ID, Groupid FROM contacts WHERE PPID='" & Replace(Login, "'", "''") & "' AND Pwd='" & Replace(Password, "'", "''") & "'"  
    SQL = "SELECT ID, mailstop, Groupid FROM contacts WHERE PPID='" & Replace(Login, "'", "''") & "' AND Pwd='" & Replace(Password, "'", "''") & "'"  
	Set RecordSet = Connection.Execute(SQL)  
    Result = (Connection.Errors.Count = 0)  
    If Result Then _  
        Result = NOT RecordSet.EOF  
    If Result Then  
        UserIDField = CStr(RecordSet("ID").Value)  
		mailstopField = CStr(RecordSet("mailstop").Value) 'added  
        Session("UserID") = UserIDField  
        Session("UserLogin") = Login  
        Session("mailstop") = mailstopField 'Added  
	    Set GroupIDField = RecordSet("Groupid")  
        Select Case GroupIDField.Type  
            Case adBigInt, adUnsignedBigInt  
                GroupIDField = CLng(GroupIDField.Value)  
            Case adBoolean  
                GroupIDField = CBool(GroupIDField.Value)  
            Case adBSTR, adChar, adVarChar, adLongVarChar, adLongVarWChar, adVarWChar, adWChar  
                GroupIDField = CStr(GroupIDField.Value)  
            Case adCurrency  
                GroupIDField = CCur(GroupIDField.Value)  
            Case adDate, adDBDate  
                GroupIDField = CDate(GroupIDField.Value)  
            Case adDecimal, adDouble, adNumeric, adVarNumeric  
                GroupIDField = CDbl(GroupIDField.Value)  
            Case adEmpty  
                GroupIDField = Empty  
            Case adInteger, adSmallInt, adTinyInt, adUnsignedInt, adUnsignedSmallInt  
                GroupIDField = CInt(GroupIDField.Value)  
            Case adSingle  
                GroupIDField = CSng(GroupIDField.Value)  
            Case adUnsignedTinyInt  
                GroupIDField = CByte(GroupIDField.Value)  
            Case Else  
                GroupIDField = GroupIDField.Value  
        End Select  
        Session("GroupID") = GroupIDField  
    End If  
    If RecordSet.State = adStateOpen Then _  
        RecordSet.Close  
    Set RecordSet = Nothing  
    If Connection.State = adStateOpen Then _  
        Connection.Close  
    Set Connection = Nothing  
    CCLoginUser = Result  
End Function  
'End CCLoginUser  
  
'CCLogoutUser @0-DB93CE50  
Sub CCLogoutUser()  
    Session("UserID") = Empty  
    Session("UserLogin") = Empty  
    Session("GroupID") = Empty  
	Session("mailstop") = Empty 'Added  
End Sub  
'End CCLogoutUser


_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 11/05/2009, 7:10 AM

No need to change common.asp (well the Core code)

also where did you put this:

  
'Custom Code @24-73254650 ' -------------------------       
Dim Connection1         
Set Connection1 = New clsDBNetops          
Connection1.Open          
Session("mailstop") = CCDLookUp("mailstop","contacts","ID="& Connection1.ToSQL(CCGetUserID(),ccsInteger), Connection1) 	     
Session.Timeout = 1440 	     
Connection1.Close         
Set Connection1 = Nothing      
'  ------------------------- 'End Custom Code  

i have a small code that shoudl work no matter what but first could you tell em where this code was localed?
what event?

also where are you usingf Session("mailstop")???

Grid? filter? (in one specific ASP progrma)? varouis ASPProgram?

WebHosting? or Server IIS owner?

and last:
Problem is only with Session("mailstop") all with all Session?


_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DJJWP


Posts: 77
Posted: 11/05/2009, 10:56 AM

This was placed into the Client On Click as custom code on the logon page. I have also tried to add it to the server side and that did not work as well.

So far, since placing it in common, I have not had anyone loose the variable.
_________________
Network Operations Rule
View profile  Send private message
DJJWP


Posts: 77
Posted: 11/05/2009, 2:21 PM

Thought I had this licked but I just had another user report a failure.
:-@
_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 11/10/2009, 3:37 PM

Quote :
also where are you using Session("mailstop")???

Grid? filter? (in one specific ASP progrma)? various ASP Program?


_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
DJJWP


Posts: 77
Posted: 11/11/2009, 5:31 AM

It goes into a hidden field on a data entry form. When the user opens the form to add a record, it is the default value of that hidden field. This permits me to know where the issue is reported by identifying where the user is. This custom variable is the only one that seems to time out and now does so only when the user has not fully logged out at some point in 24 hours.

Note that the other normal variables are still active!
_________________
Network Operations Rule
View profile  Send private message
Oper


Posts: 1190
Posted: 11/13/2009, 4:23 PM

if you use remmeber me, you will not noticed the variable expiration
useirid, grupoid and Level

but the session mail stop will.

if you are using IIS from a hosting (hosting owner could negate the session variabl extension using IIS 2008 or any 3er party software)

also iis could reset for so many reason for other Domain, if your doamin is in the same app Pool, your section will ve reset too, but cuase you are using remember-me feature you wont notice the reset for the userid,groupid and level, casue CCS wil take care of them, but ther other session variable will be reset

but locating the session(mailstop) in the common.asp should work always cause AutoLoginCheck/remember me call that function. (but be ready for ccs upgrade/trouble in case they change this part)

Maybe i could help you more if i understand why you need to save a variable session of the mail if that is something you could always get at any time.

for ex

* why you dont use on the defaul value (onbeforeshow) the CCDlookup?
* why dont use Cookies?


wish i coudl help more.




_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.