php - Check/Validate and reuse CodeIgniter session -


i have website website 20 api calls (rest). every call user/pass input required.

the api calls can made c++, python, php, java, asp etc...

the issue have creates tons of sessions. want change allow calls re-use session id assigned.

so first call "authenticate", return token (encrypted session id)

then decrypt token , check if session id exists in database. if does, want load or assign session

i found pge ellislab explaining session not me since page creates new session.

example:

call #1: authenticate(user,password)

call #2: get_report(token, 1) // report id 1

call #3: add_user(token, [array of user data])

how can reuse session in codeigniter?

you need save token in session if not exist.

1) token form request username think user name unique you.

2)

$this->load->library('session'); $user_data = $this->session->userdata('$username'); if(!empty($user_data)){ //use same session }else{ $this->session->set_userdata('$username', 'isvalid'); } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -