浏览器关闭后cookie保持的确切步骤是什么?目前我有:
createPersistentCookie设置为true在LoggedIn事件.true.只要浏览器处于打开状态,用户就会保持登录状态,但一旦关闭,并且无关紧要,用户将需要再次登录.我错过了什么?
编辑:
我浏览了marapet指出的文章(见下面的评论),这让我对票证是否确实有IsPersistent标志感兴趣.解密的票证如下所示:
System.Web.Security.FormsAuthentication.Decrypt(Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName].Value)
{System.Web.Security.FormsAuthenticationTicket}
CookiePath: "/"
Expiration: {19/08/2010 17:27:14}
Expired: false
IsPersistent: true
IssueDate: {19/07/2010 17:27:14}
Name: "alex"
UserData: ""
Version: 2
所有细节都是正确的,并且对应于我在LoggedIn事件中设置的那些.我可以直接从cookie中检索的cookie值更多,与此相同.然而,只要我关闭浏览器,cookie就会丢失.
然而,我注意到,携带票证的cookie由于某种原因重置日期.首先,我无法覆盖web.config中的设置,因此在LoggedIn事件结束时,它的Expires属性是在发布日期后4000分钟,而不是我以编程方式设置的月份.然后在页面加载后,我使用FormsAuthentication.FormsCookieName检索的cookie具有01/01/0001的Expires属性.我想也许这就是问题所在?任何想法将不胜感激.
编辑#2: 我正在更改标题和标签以包含会话,因为它证明与问题/解决方案相关
无法找到一种方法来为我的旧问题提供赏金,所以我重新发布它,因为它可能是一个错误.
简短版本:我希望PhoneGap + JQM应用程序中的持久标头在页面转换之间保持原位(从不移动),就像页脚可以设计的那样.
长版:首先,我是jQuery和JQM的新手,所以请指出我所犯的任何新错误.
我正在尝试在应用程序中的不同页面之间保留一个标题.当用户在页面之间转换时,它必须像持久的页脚一样保持在原位.使用data-role ="footer"data-id ="(某些一致的id)"data-position ="fixed"来实现持久页脚.它运作得相当好(随机故障,因为它错位,然后在几秒后自动修复).有关我正在寻找的内容的更多信息,请参阅此处的"持久页脚":http: //jquerymobile.com/test/docs/#/test/docs/toolbars/docs-footers.html
并在下面的链接中查看持久页脚的示例.了解如何选择页脚中的项目转换为全新页面,但页脚不会移动:http: //jquerymobile.com/test/docs/#/test/docs/toolbars/footer-persist-a.html
现在我正在尝试做同样的事情,但我希望它在应用程序的顶部而不是底部.我尝试过以下的事情:
每页上的HTML:
<div data-role="footer" data-position="fixed" data-id="header">
<img src="images/bgheader.png" />
</div>
Run Code Online (Sandbox Code Playgroud)
JavaScript:
$('div.ui-footer').css('top', '0px');
$('div.ui-footer-fixed').css('top', '0px');
$('div.fade').css('top', '0px');
$('div.ui-fixed-overlay').css('top', '0px');
$('div.ui-bar-a').css('top', '0px');
Run Code Online (Sandbox Code Playgroud)
每页上的HTML:
<div data-role="header" data-position="fixed" data-id="header" id="header" data-backbtn="false">
<img src="images/bgheader.png" />
</div>
Run Code Online (Sandbox Code Playgroud) 我使用Persistent orm和scotty web框架.
我希望通过id从db获取值.这些ID来自GET请求
有"获取"功能,它接受"密钥实体"变量并返回"可能实体".
我使用以下代码从db获取值
k <- keyFromValues $ [(PersistInt64 myOwnIntVarFromRequest)]
case k of
Left _ -> {-some processing-}
Right x -> do
t <- liftIO . runDb $ get (x::Key Post) --Post is one of my models
case t of
Nothing -> {-processing-}
Just x -> {-processing-}
Run Code Online (Sandbox Code Playgroud)
这些代码非常丑陋.但我不知道如何做得更好
所以我的问题是如何在不调用keyFromValues的情况下获取"Key Entity"类型的变量.
PS抱歉我的英语不好
假设我有4个模块:Common,A,B和Main,我想要以下模式:
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Common
commonField Int
A
commonId CommonId
aField Int
B
commonId CommonId
bField Int
|]
Run Code Online (Sandbox Code Playgroud)
但是我希望将它分割为Common,A和B模块.然后,我希望Main依赖于所有这些并包含数据库逻辑.
我尝试了以下(忽略B)
-- module Common
share [mkPersist sqlSettings, mkMigrate "migrateCommon"] [persistLowerCase|
Common
commonField Int
|]
-- module A
share [mkPersist sqlSettings, mkMigrate "migrateA"] [persistLowerCase|
A
commonId CommonId
aField Int
|]
Run Code Online (Sandbox Code Playgroud)
但是由此产生的迁移将外部约束从A移除到Common.
我persistLowerCase在调用share之前尝试存储和连接quasiquoter 的结果,但这导致了一个关于CommonId不在范围内的类型错误.
我能想到的唯一其他解决方案是存储字符串,连接它们,并在其上调用quasiquoter,这似乎不太好.
有什么建议?
我在Java IDL中运行CORBA Persistent Object实现
我按照上面的文章中的确切程序
我使用servertool注册Persistent服务器,如例子所示.但当我尝试使用该文章中的语法注册服务器时:
servertool > register -server PersistentServer -applicationName s1
-classpath path_to_server_class_files
我挂起来并没有做任何事情,然后我必须做ctrl+c回到正常模式
这可能有什么问题?
我想写简化了使用写CRUD后端一个类型类持久性,埃宋和斯科蒂
这是我的想法:
runDB x = liftIO $ do info <- mysqlInfo
runResourceT $ SQL.withMySQLConn info $ SQL.runSqlConn x
class (J.FromJSON a, J.ToJSON a, SQL.PersistEntity a) => CRUD a where
getBasePath :: a -> String
getCrudName :: a -> String
getFromBody :: a -> ActionM a
getFromBody _ = do body <- jsonData
return body
mkInsertRoute :: a -> ScottyM ()
mkInsertRoute el =
do post (fromString ((getBasePath el) ++ "/" ++ (getCrudName el))) $ do …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何使用Esqueleto编写以下查询
SELECT COUNT("person"."id")
FROM "person"
WHERE (("person"."admin" = 't' OR "person"."vip" = 't') // 't' as in True
OR "person"."karma" >= 5000 AND "person"."hellbanned" = 'f')
Run Code Online (Sandbox Code Playgroud)
这是我的模型的定义方式
Person
admin Bool
vip Bool
karma Int
hellbanned Bool
Run Code Online (Sandbox Code Playgroud)
除了COUNT部分之外,我已经成功获得了所有东西
select $
from $ \p -> do
where_
((p ^. PersonAdmin ==. val True) ||. (p ^. PersonVip ==. val True)
&&. (p ^. PersonKarma >=. val 5000) &&. (p ^. PersonHellbanned ==. val False))
return $ p ^. PersonId
Run Code Online (Sandbox Code Playgroud)
我设法找到了一个 …
我能找到的关于Persistent的所有教程和参考都非常详细地描述了Persistent如何在DSL中的单个定义中自动创建新的数据类型,模式,迁移等.但是,我找不到有关如何使Persistent处理现有数据类型的解释.
一个例子:假设我有一个已经存在的Haskell模块用于某些游戏逻辑.它包括玩家的记录类型.(它意味着通过镜头使用,因此是下划线.)
data Player = Player { _name :: String
, _points :: Int
-- more fields ...
}
$(makeLenses ''Player)
Run Code Online (Sandbox Code Playgroud)
问题:使用Persistent将这种类型存储在数据库中的规范方法是什么?我可以实现一些类型类吗?或者我应该通过Persistent最好地定义一个新类型,例如
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
PlayerEntry
name Text
points Int
|]
Run Code Online (Sandbox Code Playgroud)
然后在这些类型之间手动映射?
playerToEntry :: Player -> PlayerEntry
playerToEntry pl = PlayerEntry (pl^.name) (pl^.points)
entryToPlayer :: PlayerEntry -> Player
entryToPlayer e = Player (name e) (points e)
Run Code Online (Sandbox Code Playgroud) 我正在使用Python for Windows的程序,并希望保存变量和用户首选项,以便即使在程序终止并重新启动后我也可以调用它们.
有没有理想的方法在Windows机器上执行此操作?是否_winreg和Windows注册表适合这项任务?或者我是否需要创建自己的某种数据库?
对于像这样的数据类型
data Tree = Node String Tree Tree
| Leaf String
Run Code Online (Sandbox Code Playgroud)
和真实的数据一样
my_tree = (Node "first node" (Leaf "leaf") (Node "second node" (Leaf "leaf") (Leaf "leaf")))
Run Code Online (Sandbox Code Playgroud)
如何使用持久性将其存储到数据库中,具体如何执行"OR"部分?
我试过像这样定义模型
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Tree
value String
leftTree Leaf
rightTree Leaf
deriving Show
Leaf
value String
deriving Show
|]
Run Code Online (Sandbox Code Playgroud)
递归结构将作为json字符串自动存储在一行中的列中,这非常好.但是我们如何或者可以在持久模型中定义"OR"结构?