Warning: Illegal session variable value


When creating a session variable, only character data can be assigned. A warning message is logged if the data assigned to the session variable is not a character type.


A variable in Xbasic has a type. This can be character, numeric, date, time, shorttime, etc. However, session variables should only be character variables. If you try to set a session variable to a non-character value, the Xbasic Error log will show a warning:

Warning: Illegal session variable value.
    Session variables are restricted to character type only.
    The variable Session.my_date is about to be set with as non-character value.
    This code will no longer function in a future software release.

To prevent the warning, you must cast the value you want to store in a session variable to a character value before setting the session variable. The easiest way to cast a value to a character is to concatenate it with an empty character value. For example:

dim number as n = 5
dim string as c
string = "" + number

For more information on using session variables and how to convert session variable data to and from a string data type, see Understanding Session Variables: Session Variable Types.