Jump to content

Using $session


Jon
 Share

Recommended Posts

Hello,

Iam just wondering is this would be the right away to go about this.

So I have a order form on my site which will store my order as a $session before transferring away to my payment gateway (WorldPay). I'll be passing the order number from the $session within payment. Once the payment has been processed/cancel/declined the user will be redirected back to a confirmation page which will display the relevant information and if the order is process ill be using the $session data to generate a order (page)

Iam just wondering if that's a ok use of $session?

Cheers

Jon

Link to comment
Share on other sites

Hi,

I'm currently implementing similar functionality for my project. $session seems to work as expected. However, I want to ask PW gurus, what are advantages of PW $session compared to regular PHP $_SESSION? It seems they basically do the same things, $session can be used as $session in template files and should be used as $this->session in module files.

Are there any pros for $session except for chaining?

Link to comment
Share on other sites

Are there any pros for $session except for chaining?

I think yes, some usage examples:

//validate user
$session->isValidSession($userID)

//get the IP address of the current user
$session->getIP()

// login a user
$session->login($name, $pass)

// login a user without requiring a password
$session->forceLogin($user)

// return true or false whether the user authenticated with the supplied password
$session->authenticate(User $user, $pass)

// logout the current user, and clear all session variables
$session->logout()

// redirect this session to another URL
$session->redirect($url)

// get the session history (if enabled)
$session->getHistory()

Further informations:

https://processwire.com/apigen/class-Session.html

http://cheatsheet.processwire.com/

http://processwire.com/api/variables/session/

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...