cookies

C#: Writing a CookieContainer to Disk and Loading Back In For Use

I have a CookieContainer extracted from a HttpWebRequest/HttpWebResponse session named CookieJar. I want my application to store cookies between runs, so cookies collected in the CookieContainer on one run of the program will be used the next run, too. I think the way to do this would be to somehow write the contents of a CookieContaine...

C#: Using CookieContainer with WebClient class

I've previously used a CookieContainer with HttpWebRequest and HttpWebResponse sessions, but now, I want to use it with a WebClient. As far as I understand, there is no built-in method like there is for HttpWebRequests (request.CookieContainer). How can I collect cookies from a WebClient in a CookieContainer? I googled for this and foun...

PHP: Preventing Session Hijacking with token stored as a cookie?

Hi. I'm working on an RIA in PHP. To try to prevent session hijacking I introduced a token, generated at login, based off a salt, ISO-8601 week number and the user's IP. $salt = "blahblahblah"; $tokenstr = date('W') . $salt . $_SERVER['REMOTE_ADDR']; $token_md5 = md5($tokenstr); define("token_md5", $token_md5); Currently, it's...

C# (Sharp) The Difference between HttpCookie and Cookie?

So I'm confused as msdn and other tutorials tell me to use HttpCookies to add cookies via Response.Cookies.Add(cookie). But that's the problem. Response.Cookies.Add only accepts Cookies and not HttpCookies and I get this error: cannot convert from 'System.Net.CookieContainer' to 'System.Net.Cookie' Additionally, what's the difference b...

How do I set cookie expiration to "session" in C#?

Self-Explanatory. In PHP, the solution would be to set the cookie expiration to 0; I'm unsure about C# since it requires a DateTime value. ...

How to use PHP control concurrent users

I am using PHP + MySQL. Is there anyway I can control concurrent user (1 user with only 1 key) to access my php page? Not allow copy the key to access from different machine into my php, how to handle this through my php sessions/cookies? Any advise would be appreciated! ...

Clear cookies on browser close

How to clear the cookies that has been stored through my asp.net mvc(C#) application, when the user closes the browser? Is there any option to create a cookie such that it expires once the browser closed? I need to use cookies, because i will store some of the values to be maintained until the browser is closed. For example, During si...

Is it safe to store user object in a cookie?

I have a user object which contains information about the user (username, ip, country, name, email... but NOT password). Should I store just the username in the cookie and then retrieve all info from DB upon loading the page, or just store the entire User object in the cookie? ...

Multiple function calls, only the last succeeds. Why?

I store an array of values in my cookie as a string (with ',' as separator). I update them using explode(), implode() and setcookie() methods in a custom function set_Cookie() and it works great. function set_Cookie($name, $position, $value) { $cookie = ($_COOKIE[$name]); $cookie_exp = explode(",", $cookie); $cookie_exp[$pos...

Cookies of domain are sent to subdomain, how to fix?

Firefox is sending my ".domain.tld" cookies when I go to sub.domain.tld. How can I make sure that the browser only sends cookies of ".sub.domain.tld" and not ".domain.tld"? ...

How do I assign a non-persistent (in-memory) cookie in ASP.NET?

The following code will send a cookie to the user as part of the response: var cookie = new HttpCookie("theAnswer", "42"); cookie.Expires = DateTime.Now.AddDays(7); Response.Cookies.Add(cookie); The cookie is of the persistent type, which by most browsers will be written to disk and used across sessions. That is, the cookie is still o...

How do I set cookies using Perl CGI?

I have tried without success setting cookies using Perl CGI. My code looks like this: $qry = new CGI $cookie = $qry->cookie(-name=>'SERVER_COOKIE', -value=>'USER_NAME', -path=>'/'), $qry->header(-cookie=>$cookie) The page does not throw any error, but no cookie gets set! I am using Fire...

How do I design a Perl cookie initialization login screen?

Guys, Based on this question I asked earlier on setting up cookies in Perl, I successfully got an answer and way to do this but am now faced with a new interesting challenge. In Perl CGI scripts, it demands you setup a cookie on the header statement which ought to be the first statement in your script. To clarify, you need to have a CGI...

How to remove cookie with underscore in name in VB6?

I have VB6 web application and I have to remove cookie. Unfortunately cookie has underscore character in name -- exemplary cookie name looks like that: XXXXXXAAASS_session_key. When I try to remove it by assign empty value to it: Response.cookies.Item("XXXXXXAAASS_session_key") = "" I've got a new cookie with name `XXXXXXAAASS%5Fsess...

Some cookies not sent to server

I am attempting to set a cookie on a particular page to be read on another page. I wish to know why the other page is not being sent the cookie. Examining what is going on shows that the cookie is being set, but is not being sent to the server. My understanding was that if the path of a cookie is not set, the cookie will be sent to an...

is it possible to not display login screen in remember me in spring security ?

I have implemented spring security's remember me feature in our app, the way i understand it, If user opens main page directly and he is not authenticated by spring, he is taken to the login page. if he is authenticated, he stays on the main page. However in our application, the user is likely to start the login page first (and is likel...

Manual authentication in spring using the rememember me cookie

I have a requirement by which I need to detect user authorization in the login screen itself. (refer to my Previous Question) I tried and searched for a cookie by name SPRING_SECURITY_REMEMBER_ME_COOKIE I found one and its value is hashed... Is it possible for Login to make an ajax call to the server with the value of this cookie and au...

About cookie expiration

If I set cookie to expire in 1 month. But during that month,I visit the site every day. Will the cookie still expire after 1 month? ...

Set expiration date for cookie from different domain

Is there any way I can set Cookie expiration date from other page - i want to delete the cookie across domain. E.g. there are two domains: first.com, second.com . From second.com i want to set expiration date for cookie from first.com. I don't have an access to first.com. ...

file_get_contents receive cookies

Is it possible to receive the cookies set by the remote server when doing a file_get_contents request? I need php to do a http request and store the cookies and make a second request. ...