uForum.uz

uForum.uz (https://uforum.uz/index.php)
-   Веб программирование (https://uforum.uz/forumdisplay.php?f=171)
-   -   Одна учетная запись для всех сайтов (https://uforum.uz/showthread.php?t=8349)

Artur Alikulov 20.03.2009 09:16

Цитата:

Сообщение от elf (Сообщение 193719)
Куки и сессия еще в моде, я тоже планирую решить задачу с ними. Проблема в том, что если сайт music.site.com на другом серваке, тогда он не сможеть получить куки сайта site.com. Или не так? Я еще не проверил. Можеть система позволяеть поддоменным сайтам получить куки их "родителей", хотя они другом серваке?

Куки создаются на стороне клиента и не важно на каких серваках будут находиться сайты.

Timur Naimov 20.03.2009 10:27

Цитата:

Сообщение от Artur Alikulov (Сообщение 193764)
Куки создаются на стороне клиента и не важно на каких серваках будут находиться сайты.

Маленькое уточнение из MSDN ;)

Цитата:

Limiting Cookies to a Folder or Application
To limit cookies to a folder on the server, set the cookie's Path property, as in the following example:

Visual Basic Copy Code
Dim appCookie As New HttpCookie("AppCookie")
appCookie.Value = "written " & DateTime.Now.ToString()
appCookie.Expires = DateTime.Now.AddDays(1)
appCookie.Path = "/Application1"
Response.Cookies.Add(appCookie)

C# Copy Code
HttpCookie appCookie = new HttpCookie("AppCookie");
appCookie.Value = "written " + DateTime.Now.ToString();
appCookie.Expires = DateTime.Now.AddDays(1);
appCookie.Path = "/Application1";
Response.Cookies.Add(appCookie);

Note:
You can also write cookies by adding them to the Cookies collection directly as shown in earlier examples.


The path can either be a physical path under the site root or a virtual root. The effect will be that the cookie is available only to pages in the Application1 folder or virtual root. For example, if your site is called www.contoso.com, the cookie created in the previous example will be available to pages with the path http://www.contoso.com/Application1/ and to any pages beneath that folder. However, the cookie will not be available to pages in other applications such as http://www.contoso.com/Application2/ or just http://www.contoso.com/.

Note:
In some browsers, the path is case sensitive. You cannot control how users type URLs into their browsers, but if your application depends on cookies tied to a specific path, be sure that the URLs in any hyperlinks you create match the case of the Path property value.


Limiting Cookie Domain Scope
By default, cookies are associated with a specific domain. For example, if your site is www.contoso.com, the cookies you write are sent to the server when users request any page from that site. (This might not include cookies with a specific path value.) If your site has subdomains—for example, contoso.com, sales.contoso.com, and support.contoso.com—then you can associate cookies with a specific subdomain. To do so, set the cookie's Domain property, as in this example:

Visual Basic Copy Code
Response.Cookies("domain").Value = DateTime.Now.ToString()
Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
Response.Cookies("domain").Domain = "support.contoso.com"

C# Copy Code
Response.Cookies["domain"].Value = DateTime.Now.ToString();
Response.Cookies["domain"].Expires = DateTime.Now.AddDays(1);
Response.Cookies["domain"].Domain = "support.contoso.com";


When the domain is set in this way, the cookie will be available only to pages in the specified subdomain. You can also use the Domain property to create a cookie that can be shared among multiple subdomains, as shown in the following example:

Visual Basic Copy Code
Response.Cookies("domain").Value = DateTime.Now.ToString()
Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
Response.Cookies("domain").Domain = "contoso.com"

C# Copy Code
Response.Cookies["domain"].Value = DateTime.Now.ToString();
Response.Cookies["domain"].Expires = DateTime.Now.AddDays(1);
Response.Cookies["domain"].Domain = "contoso.com";


The cookie will then be available to the primary domain as well as to sales.contoso.com and support.contoso.com domains.



Artur Alikulov 20.03.2009 10:40

Цитата:

Сообщение от Timur Naimov (Сообщение 193826)
Маленькое уточнение из MSDN

Не пугай топикстартера MSDN'ом ;) Он на ПХП пишет, хотя и там уверен есть возможность ограничения использования куков субдоменами и т.д.

Timur Naimov 20.03.2009 11:09

Цитата:

Сообщение от Artur Alikulov (Сообщение 193835)
Не пугай топикстартера MSDN'ом Он на ПХП пишет, хотя и там уверен есть возможность ограничения использования куков субдоменами и т.д.

Это я к тому, что надо пользоваться "правильными" технологиями :) (сейчас тапками закидают...)

DarkUser 20.03.2009 12:10

Оффтоп:
Цитата:

Сообщение от Timur Naimov (Сообщение 193847)
Это я к тому, что надо пользоваться "правильными" технологиями

в IT среде принято сначала мозгами пользоваться, а потом уже технологиями :)

elf 20.03.2009 13:24

Цитата:

Сообщение от Artur Alikulov (Сообщение 193764)
Цитата:

Сообщение от elf (Сообщение 193719)
Куки и сессия еще в моде, я тоже планирую решить задачу с ними. Проблема в том, что если сайт music.site.com на другом серваке, тогда он не сможеть получить куки сайта site.com. Или не так? Я еще не проверил. Можеть система позволяеть поддоменным сайтам получить куки их "родителей", хотя они другом серваке?

Куки создаются на стороне клиента и не важно на каких серваках будут находиться сайты.

Итак, Вы предлаете создать куки с ограничениями домена (конечно данные храниться в зашифрованном виде). То есть куку установим в виде
setcookie("name", $value, "", ".site.com");
Лишь этого достаточно? И как будет по мере безопасности?


Текущее время: 15:40. Часовой пояс GMT +5.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
OOO «Единый интегратор UZINFOCOM»