Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9092263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:47:57+00:00 2026-06-16T22:47:57+00:00

I am developing a website with Yii. I have a button in the page.

  • 0

I am developing a website with Yii.

I have a button in the page. I need to set a session variable when user clicks it and get the session value when user clicks on another button.

How can I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:47:58+00:00Added an answer on June 16, 2026 at 10:47 pm

    Use CWebUser state methods

    //set session variable
    Yii::app()->user->setState("state_name", "value");
    
    //check session variables
    Yii::app()->user->hasState("state_name");
    
    //get session variable
    Yii::app()->user->getState("state_name");
    
    //delete session variable (thanks @Kailas)
    Yii::app()->user->setState("state_name", null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a website in which a cookie is set when the user
I am developing a website that requires several user types. I have been able
I am developing a project with Yii framework. I need to organized website users
I have been working on developing an image gallery website in yii framework. I
I'm developing a website and I need to get the pretty url. After a
Am developing one website for which I have to do user login and registration
When developing a website, I often need to test scenarios like this: When user
I am developing my first YII website. I have a couple of doubts about
I'm developing a website for a client of ours and have been having a
I am developing a website in asp.net using dotnetnuke cms. I need to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.