简体   繁体   English

如何在php中获取会话变量值?

[英]how to get session variable value in php?

Inside my code i can see one session and once i printed that session i got following things in view source 在我的代码内,我可以看到一个会话,一旦我打印了该会话,我就会在视图源中关注以下内容

Array
(
    [Config] => Array
        (
            [time] => 1406983421
            [timeout] => 10
        )

    [loggedIn] => 1
    [user] => Array
        (
            [User] => Array
                (
                    [id] => 424

                    [correspondence_email] => 
                    [terms] => Y
                    [old_facebook] => 
                    [[old_twitter] => 
                    [gmail_email] => 
                     [login_count] => 9
                    [last_secdeg_updated] => 2014-08-01 08:47:35
                )

        )
)

then i tried this line to get the value of "login_count" 然后我尝试了这一行以获得“ login_count”的值

echo "value".$this->Session->read("login_count");

but am not able to see this the "login_count" in echo. 但无法在echo中看到“ login_count”。 am getting only this result in viewsource 在viewsource中只得到这个结果

value

How do i get "login_count" vale to a variable.? 如何获取“ login_count”变量的值?

 echo $this->Session->read('user.User.login_count');

我希望这可以帮助你。

没有看到编写该会话的代码,我怀疑这是您要查找的内容:

echo $this->Session->read('user.User.login_count');

You dont have to create any codes to perfom session operations.They are already built in the cake php api.You just need to read and write the sessions from the link i given below. 您不必创建任何代码来执行会话操作。它们已经内置在Cake php API中。您只需要从下面给出的链接中读取和写入会话即可。

http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html Used in Controllers

http://book.cakephp.org/2.0/en/core-libraries/helpers/session.html Used in Views

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM