Page 1 of 1

$_SESSION variables

Posted: Wed Mar 05, 2025 3:30 pm
by Philo2005
Hi Developers!

1. I would like to know where the variables of $_SESSION['variablename'] are beeing set up by Phoenix?
I could not find that piece of code yet.
2. How can I set $_SESSION['languages_id'] (Language) to a different value like '2' -> german?

Thanks for a feedback.

Re: $_SESSION variables

Posted: Thu Mar 06, 2025 10:04 pm
by frankl
When would you like to set it? On initial page load by customer? After login?

Re: $_SESSION variables

Posted: Fri Mar 07, 2025 3:23 am
by ecartz
1. All over the place. They are usually given their initial values in the system hooks.
2. Just change German to be the default. Remove any languages that you don't want to use.

User guide link to setting up languages: https://phoenixcart.org/phoenixcartwiki ... _Languages

You also may want to make sure that your browser's Accept Language header is configured correctly: https://www.w3.org/International/questi ... priorities

Phoenix uses the Accept Language header to guess at what the user wants the language to be.

You can also turn on the language module in the header to allow the user to select a different language.

Re: $_SESSION variables

Posted: Fri Mar 07, 2025 6:29 pm
by Philo2005
frankl wrote: Thu Mar 06, 2025 10:04 pm When would you like to set it? On initial page load by customer? After login?
I did a try on login.php page after postLogin hook with the following statements and tried to get the language code set properly by using the parameter ?language=xx (where xx is the language code "en" or "de" in my configuration) in the url. This is my draft which should hopefully do the job:

Code: Select all

	
$customers_query = tep_db_query("SELECT c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_language_id FROM customers c WHERE c.customers_id = '" . (int)$login_customer_id. "'");
$customers = tep_db_fetch_array($customers_query);

$lng = $customers['customers_language_id'];
$languages_string = '';
$languages_query = tep_db_query("SELECT la.languages_id, la.code FROM languages la WHERE la.languages_id = '" . (int)$lng . "'");
$languages = tep_db_fetch_array($languages_query);
$langcode = $languages['code'];
$langpara = "language=" . $langcode;
$back = sizeof($_SESSION['navigation']->path)-2;
tep_redirect(tep_href_link($_SESSION['navigation']->path[$back]['page'], $langpara));
What do you think about my solution?
I was not able to successfully set the $_SESSION["languages_id"] to change the language shown in the session.
The way over url parameters now works.
The $back stuff I got this statements from another add-on. This sets the previous url.

Re: $_SESSION variables

Posted: Sat Mar 08, 2025 9:23 am
by 14Steve14
I am not a coder but I do believe that the TEP function was deprecated many years ago. Not to sure what the replacement is but @raiwa has a helpful spreadsheet listed in his signature I believe that lists all the replacements.

Re: $_SESSION variables

Posted: Sat Mar 08, 2025 11:02 am
by burt
Philo2005 wrote: Wed Mar 05, 2025 3:30 pm Hi Developers!

1. I would like to know where the variables of $_SESSION['variablename'] are beeing set up by Phoenix?
I could not find that piece of code yet.
2. How can I set $_SESSION['languages_id'] (Language) to a different value like '2' -> german?

Thanks for a feedback.
Why not just turn on the languages box or navbar module?
Your customer could then choose which language to browse in.

You seem to be allowing the user to set what language they want to browse in.
The question is "why?"...as that seems to be adding an unnecessary complication.

Re: $_SESSION variables

Posted: Sat Mar 08, 2025 6:20 pm
by Philo2005
14Steve14 wrote: Sat Mar 08, 2025 9:23 am @raiwa has a helpful spreadsheet listed in his signature I believe that lists all the replacements.
I am using an older version of phoenix, but thank you for the tip.

Re: $_SESSION variables

Posted: Sat Mar 08, 2025 6:42 pm
by Philo2005
burt wrote: Sat Mar 08, 2025 11:02 am [Why not just turn on the languages box or navbar module?
Your customer could then choose which language to browse in.
I do use this already
burt wrote: Sat Mar 08, 2025 11:02 am The question is "why?"
Well, I am using an add-on called "localize customer", which, among other things, stores the language on the table customers and orders when he opens a profile on my site and adds orders.
I want to make sure that the language set in the customer profile and orders is used for the view in the shop and correspondence from the shop! I also wondered for future whether it makes sense to store the respective currency in the customer and order base.

Since these are defined as system values ​​($_SESSION) in Phoenix, it is not so easy to change them when necessary and activate them in the following dialog. I tried in vain to set the values ​​via $_SESSION.

But I have found a way to adopt these values ​​via the URL (program code above).
That what I post as discussion code in the forum.
Hope you understand my opinion :shock: and my english :lol: