Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Accessing Session Variables


cczernia

Recommended Posts

I am currently using the "Purchase Without an Account" (PWA) contribution. I wanted to create a button that allows the user to create an account after their purchase but first I have to test if they were using PWA. PWA stores a variable called "guest" in the session but I am having trouble accessing it. I've tried:

 

$_SESSION['guest']

/////and///// 

tep_session_register('guest');
$guest = $_SESSION['guest'];

////and ////

tep_session_register('guest');
$guest = $HTTP_POST_VARS['guest']; // saw similar in another script

 

I know the variable is in their because I checked the database with the appropriate osCid. However, I have no idea how to access these variables. How do you access session variable in OSC? Thanks in advance.

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

something like

 

<? php

if (tep_session_is_registered('customer_id')) { ''

} else { echo '<a href="' . tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>';

}

?>

 

 

It might work

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Link to comment
Share on other sites

something like

 

<? php

if (tep_session_is_registered('customer_id')) { ''

} else { echo '<a href="' . tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>';

}

?>

 

 

It might work

 

Thanks, I just realized that PWA makes the customer_id = 0 in the orders table. So, on checkout_success I can call the order that was just made and if customer_id = 0 then it writes the form. Since the customer already entered the account data for the order they pretty much just have to enter their password and click submit.

 

Still not sure how to access session variables but I solved my initial problem.

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

If it helps any, this was my first foray into the world of session variables:

 

Click Me

 

Once you create them and register them, they're just like any other PHP variable except they're "global" and they don't lose their value if the page gets refreshed (but you probably already know that).

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...