<p>I kind of doubt this is it, but Craft does have a <a href="http://buildwithcraft.com/docs/config-settings#requireMatchingUserAgentForSession" rel="nofollow">couple</a> of <a href="http://buildwithcraft.com/docs/config-settings#requireUserAgentAndIpForSession" rel="nofollow">config settings</a> that might be coming into play here.</p>

<p>You can tell if you're being affected by these by looking in your <code>craft/storage/runtime/logs</code> files and see if there are any messages being logged with a <code>[warning]</code> related to not being able to restore session.</p>

<p>If you are being affected by those, try setting both of them to false just to see if that helps.</p>

CC BY-SA 3.0
2014-07-09T19:09:33.120Z
Didn't see that error, but saw this one -  Tried to restore session from a cookie, but the given hashed database token value does not appear to belong to the given login name
user814584
CC BY-SA 3.0
2014-07-09T19:17:53.757Z
Sounds like maybe Varnish isn't letting Craft set the authentication cookie it needs for every authenticated request.
Brad Bell
CC BY-SA 3.0
2014-07-10T19:38:09.143Z
So I watched the storage/runtime/sessions and noticed that the sessions are not getting updated. All that happens is an initial session file is created, but no data is ever added to it, even though the path is write and the settings are 777.
user814584
CC BY-SA 3.0
2014-07-09T18:36:57.673Z
2014-07-09T18:36:57.673Z
Brad Bell
<p>Something to note is that Vagrant can have issues with syncing a massive amount of files. Without much information, here are a few things to maybe help you narrow it down.</p>

<ol>
<li>Check the folder sync type in your Vagrant file. Vagrant should use NFS as it offers some improvement over the alternatives.</li>
<li>Ensure that your craft config is not referencing a "hard path" to the storage directory (i.e /home/yourname/site/projectname/storage).</li>
<li>Ensure that virtual box and vagrant are using the latest versions. Virtual box tends to be the culprit with sync issues. In fact, Oracles latest version fails when trying to update itself...</li>
</ol>

<p>I know thats not too much help but I have found those to be a common issue for my setup.</p>

<p><strong><em>Also, if you are using git make sure you are ignoring the /storage directory as that will cause the same type of erratic behavior.</em></strong></p>

CC BY-SA 3.0
2014-07-09T19:23:46.853Z
2014-07-09T19:23:46.853Z
Jason McCallister
<p>I'm developing on a Virtual Box on a Mac, and every time I log into the CP, I can log in successfully and click on one (maybe two) links before getting redirected to login again. I tested this on a staging server and it's working, but not in vagrant. However, I can get other things like Wordpress to allow me to login fine on the Vagrant box, so it seems to be some combination of Craft + Vagrant issue. </p>

<p>Any thoughts on where I might look to debug?</p>

<p>Note: I understand this is probably a vagrant issue, but curious if I can get any pointers of where to start looking inside of craft to find the potential problem/incompatibility.</p>

<control-panel><cookies>
Getting redirected to login page on every other CP request when using Vagrant
# Getting redirected to login page on every other CP request when using Vagrant

(Asked by: username_0 on 2014-07-09)

I'm developing on a Virtual Box on a Mac, and every time I log into the CP, I can log in successfully and click on one (maybe two) links before getting redirected to login again. I tested this on a staging server and it's working, but not in vagrant. However, I can get other things like Wordpress to allow me to login fine on the Vagrant box, so it seems to be some combination of Craft + Vagrant issue.

Any thoughts on where I might look to debug?

Note: I understand this is probably a vagrant issue, but curious if I can get any pointers of where to start looking inside of craft to find the potential problem/incompatibility.

**Tags:** control-panel, cookies


---

## 2 answers

### Answer by username_1 on 2014-07-09. Score: 2

I kind of doubt this is it, but Craft does have a [couple](http://buildwithcraft.com/docs/config-settings#requireMatchingUserAgentForSession) of [config settings](http://buildwithcraft.com/docs/config-settings#requireUserAgentAndIpForSession) that might be coming into play here.

You can tell if you're being affected by these by looking in your `craft/storage/runtime/logs` files and see if there are any messages being logged with a `[warning]` related to not being able to restore session.

If you are being affected by those, try setting both of them to false just to see if that helps.

> **Comments:**
> **username_0**: Didn't see that error, but saw this one -  Tried to restore session from a cookie, but the given hashed database token value does not appear to belong to the given login name  
> **username_1**: Sounds like maybe Varnish isn't letting Craft set the authentication cookie it needs for every authenticated request.  
> **username_0**: So I watched the storage/runtime/sessions and noticed that the sessions are not getting updated. All that happens is an initial session file is created, but no data is ever added to it, even though the path is write and the settings are 777.  

---

### Answer by username_2 on 2014-07-09. Score: 1

Something to note is that Vagrant can have issues with syncing a massive amount of files. Without much information, here are a few things to maybe help you narrow it down.

1. Check the folder sync type in your Vagrant file. Vagrant should use NFS as it offers some improvement over the alternatives.
2. Ensure that your craft config is not referencing a "hard path" to the storage directory (i.e /home/yourname/site/projectname/storage).
3. Ensure that virtual box and vagrant are using the latest versions. Virtual box tends to be the culprit with sync issues. In fact, Oracles latest version fails when trying to update itself...

I know thats not too much help but I have found those to be a common issue for my setup.

***Also, if you are using git make sure you are ignoring the /storage directory as that will cause the same type of erratic behavior.***


---

