If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / how to add a new session variable?

how to add a new session variable?

Started by delia on 21 Sep 2011, 11:56 AM · Views: 2,462

Results 1 to 12 of 12
21 Sep 2011, 11:56 AM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #1 by delia

Drawing a blank here and I don't know if this is a zen cart question or a php question or both.

I want to add a session variable for both guest and logged in user. How/where would I do that?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

21 Sep 2011, 2:33 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #2 by ajeh

What do you want to do with the session variable?

A hint would make this easier ... :unsure:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

21 Sep 2011, 3:20 PM
#3
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #3 by delia

Ah, sorry. (I seem to be always apologizing on the forum when I post questions!)

I'm looking to set up the columns vs rows scenario for the product listing as a changeable thing for anyone. They will be able to change the listing display at will simply by clicking a button.

So I would need the session variable to be present immediately on site entry, I assume.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

21 Sep 2011, 3:56 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #4 by ajeh

You could probably add it to the bottom of the:
/includes/init_includes/init_session.php

with something like:

// bof: set $_SESSION['my_session_variable'] if not previously set
if (!isset($_SESSION['my_session_variable'])) {
  $_SESSION['my_session_variable'] = 'something';
}
// eof: set $_SESSION['my_session_variable'] if not previously set

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

21 Sep 2011, 5:53 PM
#5
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #5 by delia

Thanks, Linda!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

21 Sep 2011, 5:54 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #6 by ajeh

Sure thing ... thanks for the update that this can work for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

21 Sep 2011, 7:51 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #7 by drbyte

In the interest of preventing clashes with core files, I'd suggest putting it in its own file, in two steps, like this:

a) /includes/auto_loaders/config.your_mod_name.php```

<?php $autoLoadConfig[115][] = array('autoType'=>'init_script', 'loadFile'=> 'init_my_custom_init_code_here.php'); ``` b) /includes/init_includes/init_my_custom_init_code_here.php``` whatever session code or other stuff you need to run ```

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

21 Sep 2011, 7:52 PM
#8
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #8 by delia

Oh, good, I need that!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

21 Sep 2011, 8:18 PM
#9
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #9 by delia

I can't tell you how powerful that makes me feel! It worked!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

21 Sep 2011, 8:25 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #10 by drbyte

:clap: :D

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Oct 2011, 1:58 PM
#11
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #11 by delia

Okay, so the next question is what would make this not work? I got the mod finished and working on a default install and then went to install it on the customer's cart. The session variable is not being added to the session.

There are some mods installed, most importantly the single listing template which of course affects the product_list.php.

But I did substitute the normal one and saw no change.

So what would prevent the session initialization from working?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

13 Oct 2011, 1:51 PM
#12
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Post #12 by delia

One more bit of information: the only difference with sessions between the problem server and my server is that on his the session.use_only_cookies is turned off. Our zen cart settings for session are the same except the ssl session id:

Cookie Domain True Info
Force Cookie Use False Info
Check SSL Session ID True
Check User Agent False Info
Check IP Address False Info
Prevent Spider Sessions True Info
Recreate Session True Info
IP to Host Conversion Status true Info
Use root path for cookie path False Info
Add period prefix to cookie domain True

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo